ReportedFlagSyncTrait
Keeps the `reported` flag of a reported target (discussion post, advert, company profile) derived from its reports: the target is reported while it has at least one unresolved report. One definition for the report managers of Discussion, Bazaar and Comcat.
The flag is realigned after every change that can affect it: a saved report, updateColumns() on solved or on
the target column (a moved report leaves its old target too), a deleted report and a bulk deleteAll() (which
bypasses the delete hooks). Admin presenters never touch the flag; a solved report lets the visitor report the
target again. Realigning is best effort after the main change: a failure goes to the log, not to the user.
The host (a report manager) tells how its reports point to the target and how the target flag is read and written.
Table of Contents
Methods
- deleteAll() : Result
- updateColumns() : Result
- completedDelete() : void
- The target stops being reported when its last unresolved report is deleted.
- completedSave() : void
- A new report marks the target, an edited one realigns it.
- reportTargetField() : string
- Report property holding the target id (`messageId`, `advertId`).
- reportTargetIdOf() : int|null
- Target id of one report entity.
- reportTargetIdsOf() : array<int, int>
- Targets of the given reports, read before they change.
- syncReportedFlags() : void
- targetHasUnsolvedReports() : bool
- Whether the target has an unresolved report (a direct read, never the query cache).
- writeTargetReported() : void
- Writes the `reported` flag of the target.
Methods
deleteAll()
public
deleteAll([array<string|int, mixed> $filters = [] ]) : Result
Parameters
- $filters : array<string|int, mixed> = []
Return values
ResultupdateColumns()
public
updateColumns(int|array<int, int> $entityId, array<string, mixed> $values) : Result
Parameters
- $entityId : int|array<int, int>
- $values : array<string, mixed>
Return values
ResultcompletedDelete()
The target stops being reported when its last unresolved report is deleted.
protected
completedDelete(array<int, object> $entities, Result $result[, array<string, mixed> $meta = [] ]) : void
Parameters
- $entities : array<int, object>
- $result : Result
- $meta : array<string, mixed> = []
completedSave()
A new report marks the target, an edited one realigns it.
protected
completedSave(bool $isInsert, object &$entity[, Result|null $result = null ][, array<string, mixed> $meta = [] ]) : void
Parameters
- $isInsert : bool
- $entity : object
- $result : Result|null = null
- $meta : array<string, mixed> = []
reportTargetField()
Report property holding the target id (`messageId`, `advertId`).
protected
abstract reportTargetField() : string
Return values
stringreportTargetIdOf()
Target id of one report entity.
protected
abstract reportTargetIdOf(object $report) : int|null
Parameters
- $report : object
Return values
int|nullreportTargetIdsOf()
Targets of the given reports, read before they change.
protected
abstract reportTargetIdsOf(array<int, int> $reportIds) : array<int, int>
Parameters
- $reportIds : array<int, int>
Return values
array<int, int>syncReportedFlags()
protected
syncReportedFlags(array<int, int> $targetIds) : void
Parameters
- $targetIds : array<int, int>
targetHasUnsolvedReports()
Whether the target has an unresolved report (a direct read, never the query cache).
protected
abstract targetHasUnsolvedReports(int $targetId) : bool
Parameters
- $targetId : int
Return values
boolwriteTargetReported()
Writes the `reported` flag of the target.
protected
abstract writeTargetReported(int $targetId, bool $reported) : void
Parameters
- $targetId : int
- $reported : bool