Ratings
extends Gateway
in package
implements
DbServiceAwareInterface
Uses
DbServiceAwareTrait
Table Definition for ratings
Tags
Interfaces, Classes, Traits and Enums
- DbServiceAwareInterface
- Marker interface for classes that depend on the \VuFind\Db\Service\PluginManager
Table of Contents
- $dbServiceManager : PluginManager
- Database service plugin manager
- $tableManager : PluginManager
- Table manager
- __construct() : mixed
- Constructor
- beginTransaction() : void
- Begin a database transaction.
- commitTransaction() : void
- Commit a database transaction.
- createRow() : object
- Create a new row.
- deleteByUser() : void
- Deletes all ratings by a user.
- getCountsForResource() : array<string|int, mixed>
- Get rating breakdown for the specified resource.
- getDbService() : T
- Get a database service object.
- getDbServiceManager() : PluginManager
- Get the service plugin manager. Throw an exception if it is missing.
- getDbTable() : Gateway
- Get access to another table.
- getForResource() : array<string|int, mixed>
- Get average rating and rating count associated with the specified resource.
- getStatistics() : array<string|int, mixed>
- Get statistics on use of ratings.
- initializeFeatures() : void
- Initialize features
- rollBackTransaction() : void
- Roll back a database transaction.
- setDbServiceManager() : void
- Set the service plugin manager.
Properties
$dbServiceManager
Database service plugin manager
protected
PluginManager
$dbServiceManager
$tableManager
Table manager
protected
PluginManager
$tableManager
Methods
__construct()
Constructor
public
__construct(Adapter $adapter, PluginManager $tm, array<string|int, mixed> $cfg[, RowGateway $rowObj = null ][, string $table = 'ratings' ]) : mixed
Parameters
- $adapter : Adapter
-
Database adapter
- $tm : PluginManager
-
Table manager
- $cfg : array<string|int, mixed>
-
Laminas configuration
- $rowObj : RowGateway = null
-
Row prototype object (null for default)
- $table : string = 'ratings'
-
Name of database table to interface with
Return values
mixed —beginTransaction()
Begin a database transaction.
public
beginTransaction() : void
Tags
Return values
void —commitTransaction()
Commit a database transaction.
public
commitTransaction() : void
Tags
Return values
void —createRow()
Create a new row.
public
createRow() : object
Return values
object —deleteByUser()
Deletes all ratings by a user.
public
deleteByUser(User $user) : void
Parameters
- $user : User
-
User object
Return values
void —getCountsForResource()
Get rating breakdown for the specified resource.
public
getCountsForResource(string $id, string $source, array<string|int, mixed> $groups) : array<string|int, mixed>
Parameters
- $id : string
-
Record ID to look up
- $source : string
-
Source of record to look up
- $groups : array<string|int, mixed>
-
Group definition (key => [min, max])
Return values
array<string|int, mixed> —Array with keys count and rating (between 0 and 100) as well as an groups array with ratings from lowest to highest
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 access to another table.
public
getDbTable(string $table) : Gateway
Parameters
- $table : string
-
Table name
Return values
Gateway —getForResource()
Get average rating and rating count associated with the specified resource.
public
getForResource(string $id, string $source, int|null $userId) : array<string|int, mixed>
Parameters
- $id : string
-
Record ID to look up
- $source : string
-
Source of record to look up
- $userId : int|null
-
User ID, or null for all users
Return values
array<string|int, mixed> —Array with keys count and rating (between 0 and 100)
getStatistics()
Get statistics on use of ratings.
public
getStatistics() : array<string|int, mixed>
Return values
array<string|int, mixed> —initializeFeatures()
Initialize features
public
initializeFeatures(array<string|int, mixed> $cfg) : void
Parameters
- $cfg : array<string|int, mixed>
-
Laminas configuration
Return values
void —rollBackTransaction()
Roll back a database transaction.
public
rollBackTransaction() : void
Tags
Return values
void —setDbServiceManager()
Set the service plugin manager.
public
setDbServiceManager(PluginManager $manager) : void
Parameters
- $manager : PluginManager
-
Plugin manager