RevisionService
in package
implements
IRevisionService
Records and retrieves content revisions for pages and posts.
Each save produces an immutable snapshot of the content together with the user who made the change. Snapshots are never modified or deleted, so the full edit history is preserved.
Table of Contents
Interfaces
- IRevisionService
- Contract for recording and retrieving content revisions.
Properties
Methods
- __construct() : mixed
- find() : Revision|null
- Find a single revision by ID.
- listForPage() : array<string|int, Revision>
- List revisions for a page, newest first.
- listForPost() : array<string|int, Revision>
- List revisions for a post, newest first.
- recordPage() : Revision|null
- Record a revision for a page.
- recordPost() : Revision|null
- Record a revision for a post.
- currentUserId() : int|null
- Resolve the current authenticated user id, if available.
- currentUserName() : string|null
- Resolve a display name for the current user, if available.
- record() : Revision
- Build and persist a revision snapshot.
Properties
$_repository
private
IRevisionRepository
$_repository
Methods
__construct()
public
__construct(IRevisionRepository $repository) : mixed
Parameters
- $repository : IRevisionRepository
find()
Find a single revision by ID.
public
find(int $id) : Revision|null
Parameters
- $id : int
Return values
Revision|nulllistForPage()
List revisions for a page, newest first.
public
listForPage(int $pageId) : array<string|int, Revision>
Parameters
- $pageId : int
Return values
array<string|int, Revision>listForPost()
List revisions for a post, newest first.
public
listForPost(int $postId) : array<string|int, Revision>
Parameters
- $postId : int
Return values
array<string|int, Revision>recordPage()
Record a revision for a page.
public
recordPage(Page $page, string $action) : Revision|null
Parameters
- $page : Page
- $action : string
-
One of Revision::ACTION_*
Return values
Revision|null —Null when the page has no id yet
recordPost()
Record a revision for a post.
public
recordPost(Post $post, string $action) : Revision|null
Parameters
- $post : Post
- $action : string
-
One of Revision::ACTION_*
Return values
Revision|null —Null when the post has no id yet
currentUserId()
Resolve the current authenticated user id, if available.
private
currentUserId() : int|null
Return values
int|nullcurrentUserName()
Resolve a display name for the current user, if available.
private
currentUserName() : string|null
Return values
string|nullrecord()
Build and persist a revision snapshot.
private
record(string $contentType, int $contentId, string $title, string $status, array<string|int, mixed> $snapshot, string $action) : Revision
Parameters
- $contentType : string
- $contentId : int
- $title : string
- $status : string
- $snapshot : array<string|int, mixed>
- $action : string