WorkItemComment
extends BaseEntity
in package
implements
OwnerAwareInterface, IdentifiableInterface
uses
IdentifiableTrait
Comment on a single work item (`WorkItem`): internal communication between company and client.
Deliberately does not use the shared CommentThread: a thread would be created for every work
item even without a comment, and none of the comment system features are needed here (no
nesting via parent_id, no moderation via approved/reported, no language). A flat table
avoids all of that. For the same reason this entity has no nested replies, approval, reporting
or per-language variants; adding them is a new stage, not an add-on.
authorName is a snapshot of the name at write time, not a join to the user, so renaming an
account never rewrites history. userId is optional: an admin can write a comment on behalf
of someone who is not logged in.
Unread tracking: the pair byClient + readDatetime serves both sides with one mechanism.
byClient says who wrote, readDatetime says when the other side saw it. Unread for the
admin is byClient = true with readDatetime = null, for the client the opposite. A comment
is marked when it is displayed, not when it is clicked.
NOTE: the company is one subject, so a comment read by one admin counts as read for all. Per-user tracking would need another growing table, which is what the separate table avoids.
Attributes
- #[MappedSuperclass]
- #[TableAlias]
- $alias: 'workItemComment'
Table of Contents
Interfaces
- OwnerAwareInterface
- Entity that knows who created it (the owner is the author or sender of the record); the named entry point to the generic base of the conditional RBAC role `owner`.
- IdentifiableInterface
- Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).
Properties
- $authorName : string
- $byClient : bool
- $deleted : bool
- $id : int|null
- $insertDatetime : DateTime
- $ip : string|null
- $readDatetime : DateTime|null
- $text : string
- $userId : int|null
- $workItemId : int
Methods
- __construct() : mixed
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getAuthorName() : string
- getId() : int|null
- getInsertDatetime() : DateTime
- getIp() : string|null
- getOwnerUserId() : int|null
- Returns the id of the user who created the record; `null` for an unknown or anonymous owner.
- getReadDatetime() : DateTime|null
- getText() : string
- getUserId() : int|null
- getWorkItemId() : int
- isByClient() : bool
- isDeleted() : bool
- isPersisted() : bool
- isUnread() : bool
- Returns whether the other side has not seen the comment yet.
- setAuthorName() : $this
- setByClient() : $this
- setDeleted() : $this
- setId() : $this
- setInsertDatetime() : $this
- setIp() : $this
- setReadDatetime() : $this
- setText() : $this
- setUserId() : $this
- setWorkItemId() : $this
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Properties
$authorName
protected
string
$authorName
= ''
Attributes
- #[Column]
- $name: 'author_name'
- $type: 'string'
- $length: 100
$byClient
protected
bool
$byClient
= false
Attributes
- #[Column]
- $name: 'by_client'
- $type: 'boolean'
$deleted
protected
bool
$deleted
= false
Attributes
- #[Column]
- $name: 'deleted'
- $type: 'boolean'
$id
protected
int|null
$id
= null
Attributes
- #[Column]
- $name: 'comment_id'
- $type: 'integer'
- $options: ['unsigned' => true]
- #[GeneratedValue]
- #[Id]
$insertDatetime
protected
DateTime
$insertDatetime
= new DateTime()
Attributes
- #[Column]
- $name: 'insert_datetime'
- $type: 'datetime'
$ip
protected
string|null
$ip
= null
Attributes
- #[Column]
- $name: 'ip'
- $type: 'string'
- $length: 45
- $nullable: true
- #[PersonalData]
- PersonalDataKind::Hidden
$readDatetime
protected
DateTime|null
$readDatetime
= null
Attributes
- #[Column]
- $name: 'read_datetime'
- $type: 'datetime'
- $nullable: true
$text
protected
string
$text
= ''
Attributes
- #[Column]
- $name: 'text'
- $type: 'text'
$userId
protected
int|null
$userId
= null
Attributes
- #[Column]
- $name: 'cms_system_users_user_id'
- $type: 'integer'
- $options: ['unsigned' => true]
- $nullable: true
$workItemId
protected
int
$workItemId
= 0
Attributes
- #[Column]
- $name: 'work_item_id'
- $type: 'integer'
- $options: ['unsigned' => true]
Methods
__construct()
public
__construct([int|null $id = null ][, int $workItemId = 0 ][, int|null $userId = null ][, bool $byClient = false ][, string $authorName = '' ][, string $text = '' ][, string|null $ip = null ][, DateTime $insertDatetime = new DateTime() ][, DateTime|null $readDatetime = null ][, bool $deleted = false ]) : mixed
Parameters
- $id : int|null = null
- $workItemId : int = 0
- $userId : int|null = null
- $byClient : bool = false
- $authorName : string = ''
- $text : string = ''
- $ip : string|null = null
- $insertDatetime : DateTime = new DateTime()
- $readDatetime : DateTime|null = null
- $deleted : bool = false
callInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
getAllTraits()
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>getAuthorName()
public
getAuthorName() : string
Return values
stringgetId()
public
getId() : int|null
Return values
int|nullgetInsertDatetime()
public
getInsertDatetime() : DateTime
Return values
DateTimegetIp()
public
getIp() : string|null
Return values
string|nullgetOwnerUserId()
Returns the id of the user who created the record; `null` for an unknown or anonymous owner.
public
getOwnerUserId() : int|null
Return values
int|nullgetReadDatetime()
public
getReadDatetime() : DateTime|null
Return values
DateTime|nullgetText()
public
getText() : string
Return values
stringgetUserId()
public
getUserId() : int|null
Return values
int|nullgetWorkItemId()
public
getWorkItemId() : int
Return values
intisByClient()
public
isByClient() : bool
Return values
boolisDeleted()
public
isDeleted() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolisUnread()
Returns whether the other side has not seen the comment yet.
public
isUnread() : bool
Return values
boolsetAuthorName()
public
setAuthorName(string $authorName) : $this
Parameters
- $authorName : string
Return values
$thissetByClient()
public
setByClient(bool $byClient) : $this
Parameters
- $byClient : bool
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|null $ip) : $this
Parameters
- $ip : string|null
Return values
$thissetReadDatetime()
public
setReadDatetime(DateTime|null $readDatetime) : $this
Parameters
- $readDatetime : DateTime|null
Return values
$thissetText()
public
setText(string $text) : $this
Parameters
- $text : string
Return values
$thissetUserId()
public
setUserId(int|null $userId) : $this
Parameters
- $userId : int|null
Return values
$thissetWorkItemId()
public
setWorkItemId(int $workItemId) : $this
Parameters
- $workItemId : 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>