How to Get Entity Counters
-
When a document is loaded to the session, the loaded entity will include various metadata details such as ID, current change-vector, etc.
-
If the document has Counters, the document metadata will also contain its counter names.
The counter names are available for each entity using thegetCountersFor()
method from theadvanced
session operations. -
In this page:
Get entity counters
// Load a document
$employee = $session->load(Employee::class, "employees/1-A");
// Get counter names from the loaded entity
$counterNames = $session->advanced()->getCountersFor($employee);
Syntax
public function getCountersFor(mixed $instance): ?StringList;
Parameter | Type | Description |
---|---|---|
$instance | mixed |
An instance of an entity for which counter names will be returned. |
Return Type | Description |
---|---|
?StringList |
Returns the counter names for the specified entity, or None if the entity has no counters.An exception is thrown if the entity is not tracked by the session. |