GetTrait
Find single entity by ID.
Caching lives at the Api presenter boundary (wire-payload query cache with tag versions),
not in the service. The service always reads from the database; $useCache is kept only
for backward compatible signatures and has no effect here.
Tags
Table of Contents
Methods
- exists() : bool
- Check if entity exists by ID.
- find() : T|null
- Find entity by ID.
- findOrFail() : T
- Find entity by ID or throw exception.
- findFromDb() : T|null
- Load entity from database via Mapper.
- getEntityClass() : class-string
Methods
exists()
Check if entity exists by ID.
public
exists(int|array<string|int, mixed> $id[, bool $useCache = true ]) : bool
Parameters
- $id : int|array<string|int, mixed>
-
Entity ID
- $useCache : bool = true
-
kept for backward compatibility; no effect here
Return values
bool —True if entity exists
find()
Find entity by ID.
public
find(int|array<string|int, mixed> $id[, array<string|int, mixed> $includes = [] ][, bool $useCache = true ]) : T|null
Parameters
- $id : int|array<string|int, mixed>
-
Entity ID (scalar for simple keys, array for composite keys)
- $includes : array<string|int, mixed> = []
-
Relations to load (e.g.,
['translations', 'user.roles']) - $useCache : bool = true
-
kept for backward compatibility (caching is done in the presenter); no effect here
Return values
T|null —Entity instance or null if not found
findOrFail()
Find entity by ID or throw exception.
public
findOrFail(int|array<string|int, mixed> $id[, array<string|int, mixed> $includes = [] ][, bool $useCache = true ]) : T
Parameters
- $id : int|array<string|int, mixed>
-
Entity ID
- $includes : array<string|int, mixed> = []
-
Relations to load
- $useCache : bool = true
-
kept for backward compatibility; no effect here
Tags
Return values
T —Entity instance
findFromDb()
Load entity from database via Mapper.
protected
findFromDb(int|array<string|int, mixed> $id, array<string|int, mixed> $includes) : T|null
Parameters
- $id : int|array<string|int, mixed>
-
Entity ID
- $includes : array<string|int, mixed>
-
Relations to load
Return values
T|null —Entity or null
getEntityClass()
protected
abstract getEntityClass() : class-string