CommentsService
extends AbstractDbService
in package
implements
CommentsServiceInterface, DbServiceAwareInterface, DbTableAwareInterface
Uses
DbServiceAwareTrait, DbTableAwareTrait
Database service for Comments.
Tags
Interfaces, Classes, Traits and Enums
- CommentsServiceInterface
- Database service interface for Comments.
- DbServiceAwareInterface
- Marker interface for classes that depend on the \VuFind\Db\Service\PluginManager
- DbTableAwareInterface
- Marker interface for classes that depend on the \VuFind\Db\Table\PluginManager
Table of Contents
- $dbServiceManager : PluginManager
- Database service plugin manager
- $tableManager : PluginManager
- Database table plugin manager
- addComment() : int|null
- Add a comment to the current resource. Returns comment ID on success, null on failure.
- changeResourceId() : void
- Change all matching comments to use the new resource ID instead of the old one (called when an ID changes).
- createEntity() : CommentsEntityInterface
- Create a comments entity object.
- deleteByUser() : void
- Deletes all comments by a user.
- deleteIfOwnedByUser() : bool
- Delete a comment if the owner is logged in. Returns true on success.
- getCommentById() : CommentsEntityInterface|null
- Get a comment row by ID (or return null for no match).
- getDbService() : T
- Get a database service object.
- getDbServiceManager() : PluginManager
- Get the service plugin manager. Throw an exception if it is missing.
- getDbTable() : Gateway
- Get a database table object.
- getDbTableManager() : PluginManager
- Get the table plugin manager. Throw an exception if it is missing.
- getRecordComments() : array<string|int, CommentsEntityInterface>
- Get comments associated with the specified record.
- getStatistics() : array<string|int, mixed>
- Get statistics on use of comments.
- persistEntity() : void
- Persist an entity.
- setDbServiceManager() : void
- Set the service plugin manager.
- setDbTableManager() : void
- Set the table plugin manager.
Properties
$dbServiceManager
Database service plugin manager
protected
PluginManager
$dbServiceManager
$tableManager
Database table plugin manager
protected
PluginManager
$tableManager
Methods
addComment()
Add a comment to the current resource. Returns comment ID on success, null on failure.
public
addComment(string $comment, UserEntityInterface|int $userOrId, ResourceEntityInterface|int $resourceOrId) : int|null
Parameters
- $comment : string
-
The comment to save.
- $userOrId : UserEntityInterface|int
-
User object or identifier
- $resourceOrId : ResourceEntityInterface|int
-
Resource object or identifier
Return values
int|null —changeResourceId()
Change all matching comments to use the new resource ID instead of the old one (called when an ID changes).
public
changeResourceId(int $old, int $new) : void
Parameters
- $old : int
-
Original resource ID
- $new : int
-
New resource ID
Return values
void —createEntity()
Create a comments entity object.
public
createEntity() : CommentsEntityInterface
Return values
CommentsEntityInterface —deleteByUser()
Deletes all comments by a user.
public
deleteByUser(UserEntityInterface|int $userOrId) : void
Parameters
- $userOrId : UserEntityInterface|int
-
User object or identifier
Return values
void —deleteIfOwnedByUser()
Delete a comment if the owner is logged in. Returns true on success.
public
deleteIfOwnedByUser(int $id, UserEntityInterface|int $userOrId) : bool
Parameters
- $id : int
-
ID of row to delete
- $userOrId : UserEntityInterface|int
-
User object or identifier
Return values
bool —getCommentById()
Get a comment row by ID (or return null for no match).
public
getCommentById(int $id) : CommentsEntityInterface|null
Parameters
- $id : int
-
ID of comment to retrieve.
Return values
CommentsEntityInterface|null —getDbService()
Get a database service object.
public
getDbService(class-string<\VuFind\Db\Service\T> $name) : T
Parameters
- $name : class-string<\VuFind\Db\Service\T>
-
Name of service to retrieve
Tags
Return values
T —getDbServiceManager()
Get the service plugin manager. Throw an exception if it is missing.
public
getDbServiceManager() : PluginManager
Tags
Return values
PluginManager —getDbTable()
Get a database table object.
public
getDbTable(string $table) : Gateway
Parameters
- $table : string
-
Table to load.
Return values
Gateway —getDbTableManager()
Get the table plugin manager. Throw an exception if it is missing.
public
getDbTableManager() : PluginManager
Tags
Return values
PluginManager —getRecordComments()
Get comments associated with the specified record.
public
getRecordComments(string $id[, string $source = DEFAULT_SEARCH_BACKEND ]) : array<string|int, CommentsEntityInterface>
Parameters
- $id : string
-
Record ID to look up
- $source : string = DEFAULT_SEARCH_BACKEND
-
Source of record to look up
Return values
array<string|int, CommentsEntityInterface> —getStatistics()
Get statistics on use of comments.
public
getStatistics() : array<string|int, mixed>
Return values
array<string|int, mixed> —persistEntity()
Persist an entity.
public
persistEntity(EntityInterface $entity) : void
Parameters
- $entity : EntityInterface
-
Entity to persist.
Return values
void —setDbServiceManager()
Set the service plugin manager.
public
setDbServiceManager(PluginManager $manager) : void
Parameters
- $manager : PluginManager
-
Plugin manager
Return values
void —setDbTableManager()
Set the table plugin manager.
public
setDbTableManager(PluginManager $manager) : void
Parameters
- $manager : PluginManager
-
Plugin manager