class ProductRatingRepository extends EntityRepository

Class ProductRatingRepository is injected as alligator.product_rating_repository service. ProductRatingRepository is used for crud operation for entity.

Use this class to work with database.

Traits

Class BaseRepositoryTrait. Used to provide generic CRUD operations for PrimaryKeyInterface entities

Constants

ALIAS

Alias for entity

AUTHOR_ALIAS

Alias for user entity

PRODUCT_ALIAS

Alias for product entity

Methods

save(PrimaryKeyInterface $object)

Save PrimaryKeyInterface entity

edit(PrimaryKeyInterface $object)

Edit PrimaryKeyInterface entity

bool
remove(PrimaryKeyInterface $object)

Delete PrimaryKeyInterface entity

boolean
deleteMultipleByIds(array $ids)

Delete multiple PrimaryKeyInterface entities by array of ids

boolean|string
deleteMultipleByField(string $field, array $values)

Delete multiple PrimaryKeyInterface entities by values of field

mixed
getReference(int $id, string|null $class = null)

Get reference to class

bool|string
saveMultiple(array $elements, int $flushNumber = 30)

Save multiple entities

bool|string
updateMultiple(array $elements, int $flushNumber = 30)

Edit multiple entities

bool|string
deleteMultiple(array $elements, int $flushNumber = 30)

Delete multiple enities

int
saveOrUpdateProductRating(int $productId, int $userId, int $rating)

Save/update product rating for provided product and user

array
getRatingTotalForProduct(int $productId)

Retrieve number of ratings and average average rating for provided product

array
getProductRatingRatingForUser(int $productId, int $userId)

Retrieve product rating(only value) for provided product and user

getProductRatingForUser(int $productId, int $userId)

Retrieve product rating(as object) for provided product and user

Details

in BaseRepositoryTrait at line 27
PrimaryKeyInterface save(PrimaryKeyInterface $object)

Save PrimaryKeyInterface entity

Parameters

PrimaryKeyInterface $object

Return Value

PrimaryKeyInterface

in BaseRepositoryTrait at line 48
PrimaryKeyInterface edit(PrimaryKeyInterface $object)

Edit PrimaryKeyInterface entity

Parameters

PrimaryKeyInterface $object

Return Value

PrimaryKeyInterface

in BaseRepositoryTrait at line 69
bool remove(PrimaryKeyInterface $object)

Delete PrimaryKeyInterface entity

Parameters

PrimaryKeyInterface $object

Return Value

bool FALSE on error, TRUE otherwise

in BaseRepositoryTrait at line 88
boolean deleteMultipleByIds(array $ids)

Delete multiple PrimaryKeyInterface entities by array of ids

Parameters

array $ids

Return Value

boolean

in BaseRepositoryTrait at line 101
boolean|string deleteMultipleByField(string $field, array $values)

Delete multiple PrimaryKeyInterface entities by values of field

Parameters

string $field
  • Field which will be checked
array $values
  • Values to be deleted

Return Value

boolean|string

in BaseRepositoryTrait at line 130
mixed getReference(int $id, string|null $class = null)

Get reference to class

Parameters

int $id
  • Id og reference
string|null $class
  • Class of reference

Return Value

mixed

in BaseRepositoryTrait at line 143
bool|string saveMultiple(array $elements, int $flushNumber = 30)

Save multiple entities

Parameters

array $elements
int $flushNumber

Return Value

bool|string

in BaseRepositoryTrait at line 178
bool|string updateMultiple(array $elements, int $flushNumber = 30)

Edit multiple entities

Parameters

array $elements
int $flushNumber

Return Value

bool|string

in BaseRepositoryTrait at line 213
bool|string deleteMultiple(array $elements, int $flushNumber = 30)

Delete multiple enities

Parameters

array $elements
int $flushNumber

Return Value

bool|string

at line 58
int saveOrUpdateProductRating(int $productId, int $userId, int $rating)

Save/update product rating for provided product and user

Parameters

int $productId
int $userId
int $rating

Return Value

int 200 on success, 400 on error

Exceptions

DBALException

at line 81
array getRatingTotalForProduct(int $productId)

Retrieve number of ratings and average average rating for provided product

Parameters

int $productId

Return Value

array

Exceptions

NoResultException
NonUniqueResultException

at line 105
array getProductRatingRatingForUser(int $productId, int $userId)

Retrieve product rating(only value) for provided product and user

Parameters

int $productId
int $userId

Return Value

array

at line 126
ProductRating|null getProductRatingForUser(int $productId, int $userId)

Retrieve product rating(as object) for provided product and user

Parameters

int $productId
int $userId

Return Value

ProductRating|null NULL on error, otherwise product rating entity