Rating
extends Rating
in package
One rating in two variants stored in one table (modeled after {@see Comment}): - stars only: `value` (1-5), - verbal: `value` + `text` + `pros`/`cons` (JSON arrays of strings).
response/responseDatetime hold the operator's reply. active is a persistent generated
column (deleted = 0 AND approved = 1), read-only (computed by the DB).
Attributes
- #[Entity]
- #[Table]
- $name: 'cms_mod_base_ratings'
- #[TableAlias]
- 'rating'
Table of Contents
Properties
- $active : bool
- $approved : bool
- $approvedDatetime : DateTime|null
- $cons : array<int, string>|null
- $deleted : bool
- $id : int|null
- $insertDatetime : DateTime
- $ip : string
- $pros : array<int, string>|null
- $reports : int
- $response : string|null
- $responseDatetime : DateTime|null
- $text : string|null
- $threadId : int
- $userId : int|null
- $userName : string|null
- $value : int
- $votesDown : int
- $votesUp : int
Methods
- __construct() : mixed
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- getActive() : bool
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getApproved() : bool
- getApprovedDatetime() : DateTime|null
- getCons() : array<int, string>
- getDeleted() : bool
- getId() : int|null
- getInsertDatetime() : DateTime
- getIp() : string
- getOwnerUserId() : int|null
- Returns the id of the user who created the record; `null` for an unknown or anonymous owner.
- getPros() : array<int, string>
- getReports() : int
- getResponse() : string|null
- getResponseDatetime() : DateTime|null
- getText() : string|null
- getThreadId() : int
- getUserId() : int|null
- getUserName() : string|null
- getValue() : int
- getVotesDown() : int
- getVotesUp() : int
- isActive() : bool
- isApproved() : bool
- isDeleted() : bool
- isPersisted() : bool
- isReported() : bool
- Was the review reported at least once? (admin filter)
- isReview() : bool
- Does the rating have a verbal part (text/pros/cons), not only stars?
- setApproved() : $this
- setApprovedDatetime() : $this
- setCons() : $this
- setDeleted() : $this
- setId() : $this
- setInsertDatetime() : $this
- setIp() : $this
- setPros() : $this
- setReports() : $this
- setResponse() : $this
- setResponseDatetime() : $this
- setText() : $this
- setThreadId() : $this
- setUserId() : $this
- setUserName() : $this
- setValue() : $this
- setVotesDown() : $this
- setVotesUp() : $this
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Properties
$active
protected
bool
$active
= false
Attributes
- #[Column]
- $name: 'active'
- $type: 'boolean'
- $nullable: false
- $insertable: false
- $updatable: false
- $options: ['default' => 0]
- #[FieldAccess]
- $read: Audience::All
- $insert: Audience::Privileged
- $update: Audience::Privileged
$approved
protected
bool
$approved
= false
Attributes
- #[Column]
- $name: 'approved'
- $type: 'boolean'
$approvedDatetime
protected
DateTime|null
$approvedDatetime
= null
Attributes
- #[Column]
- $name: 'approved_datetime'
- $type: 'datetime'
- $nullable: true
$cons
protected
array<int, string>|null
$cons
= null
cons (verbal variant only)
Attributes
- #[Column]
- $name: 'cons'
- $type: 'json'
- $nullable: true
$deleted
protected
bool
$deleted
= false
Attributes
- #[Column]
- $name: 'deleted'
- $type: 'boolean'
$id
protected
int|null
$id
= null
Attributes
- #[Column]
- $type: 'integer'
- $name: 'rating_id'
- $options: ['unsigned' => true]
- #[GeneratedValue]
- #[Id]
$insertDatetime
protected
DateTime
$insertDatetime
= new DateTime()
Attributes
- #[Column]
- $name: 'insert_datetime'
- $type: 'datetime'
$ip
protected
string
$ip
= ''
Attributes
- #[Column]
- $name: 'ip'
- $type: 'string'
- $length: 45
- #[PersonalData]
- PersonalDataKind::Hidden
$pros
protected
array<int, string>|null
$pros
= null
pros (verbal variant only)
Attributes
- #[Column]
- $name: 'pros'
- $type: 'json'
- $nullable: true
$reports
protected
int
$reports
= 0
Attributes
- #[Column]
- $name: 'reports'
- $type: 'integer'
- $options: ['unsigned' => true, 'default' => 0]
$response
protected
string|null
$response
= null
Attributes
- #[Column]
- $name: 'response'
- $type: 'text'
- $nullable: true
$responseDatetime
protected
DateTime|null
$responseDatetime
= null
Attributes
- #[Column]
- $name: 'response_datetime'
- $type: 'datetime'
- $nullable: true
$text
protected
string|null
$text
= null
Attributes
- #[Column]
- $name: 'text'
- $type: 'text'
- $nullable: true
$threadId
protected
int
$threadId
= 0
Attributes
- #[Column]
- $type: 'integer'
- $name: 'cms_mod_base_rating_threads_rating_thread_id'
- $options: ['unsigned' => true]
- #[FieldAccess]
- $read: Audience::All
- $insert: Audience::All
- $update: Audience::Privileged
$userId
protected
int|null
$userId
= null
Attributes
- #[Column]
- $type: 'integer'
- $name: 'cms_system_users_user_id'
- $nullable: true
- $options: ['unsigned' => true]
$userName
protected
string|null
$userName
= null
Attributes
- #[Column]
- $name: 'user_name'
- $type: 'string'
- $length: 255
- $nullable: true
$value
protected
int
$value
= 0
Attributes
- #[Column]
- $name: 'value'
- $type: 'smallint'
- $options: ['unsigned' => true, 'default' => 0]
$votesDown
protected
int
$votesDown
= 0
Attributes
- #[Column]
- $name: 'votes_down'
- $type: 'integer'
- $options: ['unsigned' => true, 'default' => 0]
$votesUp
protected
int
$votesUp
= 0
Attributes
- #[Column]
- $name: 'votes_up'
- $type: 'integer'
- $options: ['unsigned' => true, 'default' => 0]
Methods
__construct()
public
__construct([int|null $id = null ][, int $threadId = 0 ][, int $value = 0 ][, string|null $text = null ][, array<string|int, mixed>|null $pros = null ][, array<string|int, mixed>|null $cons = null ][, string|null $response = null ][, DateTime|null $responseDatetime = null ][, int|null $userId = null ][, string|null $userName = null ][, string $ip = '' ][, bool $approved = false ][, DateTime|null $approvedDatetime = null ][, bool $deleted = false ][, DateTime $insertDatetime = new DateTime() ][, bool $active = false ][, int $votesUp = 0 ][, int $votesDown = 0 ][, int $reports = 0 ]) : mixed
Parameters
- $id : int|null = null
- $threadId : int = 0
- $value : int = 0
- $text : string|null = null
- $pros : array<string|int, mixed>|null = null
- $cons : array<string|int, mixed>|null = null
- $response : string|null = null
- $responseDatetime : DateTime|null = null
- $userId : int|null = null
- $userName : string|null = null
- $ip : string = ''
- $approved : bool = false
- $approvedDatetime : DateTime|null = null
- $deleted : bool = false
- $insertDatetime : DateTime = new DateTime()
- $active : bool = false
- $votesUp : int = 0
- $votesDown : int = 0
- $reports : int = 0
callInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
getActive()
public
getActive() : bool
Return values
boolgetAllTraits()
Returns all traits the class uses, including those used by parent classes and nested traits.
public
getAllTraits() : array<string, string>
Return values
array<string, string>getApproved()
public
getApproved() : bool
Return values
boolgetApprovedDatetime()
public
getApprovedDatetime() : DateTime|null
Return values
DateTime|nullgetCons()
public
getCons() : array<int, string>
Return values
array<int, string>getDeleted()
public
getDeleted() : bool
Return values
boolgetId()
public
getId() : int|null
Return values
int|nullgetInsertDatetime()
public
getInsertDatetime() : DateTime
Return values
DateTimegetIp()
public
getIp() : string
Return values
stringgetOwnerUserId()
Returns the id of the user who created the record; `null` for an unknown or anonymous owner.
public
getOwnerUserId() : int|null
Return values
int|nullgetPros()
public
getPros() : array<int, string>
Return values
array<int, string>getReports()
public
getReports() : int
Return values
intgetResponse()
public
getResponse() : string|null
Return values
string|nullgetResponseDatetime()
public
getResponseDatetime() : DateTime|null
Return values
DateTime|nullgetText()
public
getText() : string|null
Return values
string|nullgetThreadId()
public
getThreadId() : int
Return values
intgetUserId()
public
getUserId() : int|null
Return values
int|nullgetUserName()
public
getUserName() : string|null
Return values
string|nullgetValue()
public
getValue() : int
Return values
intgetVotesDown()
public
getVotesDown() : int
Return values
intgetVotesUp()
public
getVotesUp() : int
Return values
intisActive()
public
isActive() : bool
Return values
boolisApproved()
public
isApproved() : bool
Return values
boolisDeleted()
public
isDeleted() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolisReported()
Was the review reported at least once? (admin filter)
public
isReported() : bool
Return values
boolisReview()
Does the rating have a verbal part (text/pros/cons), not only stars?
public
isReview() : bool
Return values
boolsetApproved()
public
setApproved(bool $approved) : $this
Parameters
- $approved : bool
Return values
$thissetApprovedDatetime()
public
setApprovedDatetime(DateTime|null $approvedDatetime) : $this
Parameters
- $approvedDatetime : DateTime|null
Return values
$thissetCons()
public
setCons(array<int, string>|null $cons) : $this
Parameters
- $cons : array<int, string>|null
Return values
$thissetDeleted()
public
setDeleted(bool $deleted) : $this
Parameters
- $deleted : bool
Return values
$thissetId()
public
setId(int|null $id) : $this
Parameters
- $id : int|null
Return values
$thissetInsertDatetime()
public
setInsertDatetime(DateTime $insertDatetime) : $this
Parameters
- $insertDatetime : DateTime
Return values
$thissetIp()
public
setIp(string $ip) : $this
Parameters
- $ip : string
Return values
$thissetPros()
public
setPros(array<int, string>|null $pros) : $this
Parameters
- $pros : array<int, string>|null
Return values
$thissetReports()
public
setReports(int $reports) : $this
Parameters
- $reports : int
Return values
$thissetResponse()
public
setResponse(string|null $response) : $this
Parameters
- $response : string|null
Return values
$thissetResponseDatetime()
public
setResponseDatetime(DateTime|null $responseDatetime) : $this
Parameters
- $responseDatetime : DateTime|null
Return values
$thissetText()
public
setText(string|null $text) : $this
Parameters
- $text : string|null
Return values
$thissetThreadId()
public
setThreadId(int $threadId) : $this
Parameters
- $threadId : int
Return values
$thissetUserId()
public
setUserId(int|null $userId) : $this
Parameters
- $userId : int|null
Return values
$thissetUserName()
public
setUserName(string|null $userName) : $this
Parameters
- $userName : string|null
Return values
$thissetValue()
public
setValue(int $value) : $this
Parameters
- $value : int
Return values
$thissetVotesDown()
public
setVotesDown(int $votesDown) : $this
Parameters
- $votesDown : int
Return values
$thissetVotesUp()
public
setVotesUp(int $votesUp) : $this
Parameters
- $votesUp : int
Return values
$thisgetTraitsRecursive()
Walks the trait list recursively and collects nested traits too.
private
static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
- $traits : array<string, string>