Tracking
A trait for entities which can track changes.
Instance Properties
| Name | Type | Summary |
|---|---|---|
$changes | Map<string,Map<string,mixed>> | Changes to persist. |
Instance Methods
| Returns | Signature and Description |
|---|---|
ConstMap<string,Map<string,mixed>> | Gets the pending changes. |
bool | isDirty()Whether the object has any changes. |
| Returns | Signature and Description |
|---|---|
this | aggregateChanges(, )Takes all the changes from a |
this | fieldIncrement(, )Sets a field for increment. |
this | fieldNow()Sets a field to the current date. |
this | fieldPull(, )Pulls a value from a array field. |
this | fieldPush(, )Pushes a value onto a field. |
this | fieldPushAll(, )Pushes a value onto an array field. |
this | fieldSet(, )Sets a field for update. |
this | fieldUnset()Sets a field for removal. |
Property Details
$changes
Map<string,Map<string,mixed>> $changesChanges to persist.
Method Details
aggregateChanges
aggregateChanges(Modifiable $child, string $field)Takes all the changes from a Modifiable and copies them under a field name.
| Name | Type | Description |
|---|---|---|
$child | Modifiable | The object containing updates |
$field | string | The field name |
| Type | Description |
|---|---|
this | provides a fluent interface |
fieldIncrement
fieldIncrement(string $field, int $value = 1)Sets a field for increment.
| Name | Type | Description |
|---|---|---|
$field | string | The field name |
$value | int | Optional. The increment value. Default is |
| Type | Description |
|---|---|
this | provides a fluent interface |
fieldNow
fieldNow(string $field)Sets a field to the current date.
| Name | Type | Description |
|---|---|---|
$field | string | The field name |
| Type | Description |
|---|---|
this | provides a fluent interface |
fieldPull
fieldPull(string $field, mixed $value)Pulls a value from a array field.
In addition to a single value, you can also specify a query document.
$this->fieldPull('vegetables', 'carrot');
$this->fieldPull('listOfDocs', ['foo' => 'bar']);
| Name | Type | Description |
|---|---|---|
$field | string | The field name |
$value | mixed | The value to pull |
| Type | Description |
|---|---|
this | provides a fluent interface |
fieldPush
fieldPush(string $field, mixed $value)Pushes a value onto a field.
| Name | Type | Description |
|---|---|---|
$field | string | The field name |
$value | mixed | The value to push |
| Type | Description |
|---|---|
this | provides a fluent interface |
fieldPushAll
fieldPushAll(string $field, ConstVector<mixed> $value)Pushes a value onto an array field.
| Name | Type | Description |
|---|---|---|
$field | string | The field name |
$value | ConstVector<mixed> | The values to push |
| Type | Description |
|---|---|
this | provides a fluent interface |
fieldSet
fieldSet(string $field, mixed $value)Sets a field for update.
| Name | Type | Description |
|---|---|---|
$field | string | The field name |
$value | mixed | The field value |
| Type | Description |
|---|---|
this | provides a fluent interface |
fieldUnset
fieldUnset(string $field)Sets a field for removal.
| Name | Type | Description |
|---|---|---|
$field | string | The field name |
| Type | Description |
|---|---|
this | provides a fluent interface |
getChanges
getChanges()Gets the pending changes.
| Type | Description |
|---|---|
ConstMap<string,Map<string,mixed>> | The pending changes |
isDirty
isDirty()Whether the object has any changes.
| Type | Description |
|---|---|
bool | Whether the object has any changes |