Trait TableEventsTrait
Provides model callbacks.
Method Summary
-
afterDelete() public
The Model.afterDelete event is fired after an entity has been deleted.
-
afterDeleteCommit() public
The Model.afterDeleteCommit event is fired after the transaction in which the delete operation is wrapped has been committed. It's also triggered for non atomic deletes where database operations are implicitly committed. The event is triggered only for the primary table on which delete() is directly called. The event is not triggered if a transaction is started before calling delete.
-
afterMarshal() public
The Model.afterMarshal event is fired after request data is converted into entities. Event handlers will get the converted entities, original request data and the options provided to the patchEntity() or newEntity() call.
-
afterRules() public
The Model.afterRules event is fired after an entity has rules applied. By stopping this event, you can return the final value of the rules checking operation.
-
afterSave() public
The Model.afterSave event is fired after an entity is saved.
-
afterSaveCommit() public
The Model.afterSaveCommit event is fired after the transaction in which the save operation is wrapped has been committed. It’s also triggered for non atomic saves where database operations are implicitly committed. The event is triggered only for the primary table on which save() is directly called. The event is not triggered if a transaction is started before calling save.
-
beforeDelete() public
The Model.beforeDelete event is fired before an entity is deleted. By stopping this event you will abort the delete operation. When the event is stopped the result of the event will be returned.
-
beforeFind() public
The Model.beforeFind event is fired before each find operation.
-
beforeMarshal() public
The Model.beforeMarshal event is fired before request data is converted into entities.
-
beforeRules() public
The Model.beforeRules event is fired before an entity has had rules applied. By stopping this event, you can halt the rules checking and set the result of applying rules.
-
beforeSave() public
The Model.beforeSave event is fired before each entity is saved. Stopping this event will abort the save operation. When the event is stopped the result of the event will be returned.
-
buildValidator() public
The Model.buildValidator event is fired when $name validator is created. Behaviors, can use this hook to add in validation methods.
Method Detail
afterDelete() ¶ public
afterDelete(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\Datasource\EntityInterface $entity, ArrayObject<string, mixed> $options): void
The Model.afterDelete event is fired after an entity has been deleted.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\Datasource\EntityInterface$entity Deleted entity.
-
ArrayObject<string, mixed>$options Options.
Returns
voidafterDeleteCommit() ¶ public
afterDeleteCommit(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\Datasource\EntityInterface $entity, ArrayObject<string, mixed> $options): void
The Model.afterDeleteCommit event is fired after the transaction in which the delete operation is wrapped has been committed. It's also triggered for non atomic deletes where database operations are implicitly committed. The event is triggered only for the primary table on which delete() is directly called. The event is not triggered if a transaction is started before calling delete.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\Datasource\EntityInterface$entity Deleted entity.
-
ArrayObject<string, mixed>$options Options.
Returns
voidafterMarshal() ¶ public
afterMarshal(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\Datasource\EntityInterface $entity, ArrayObject<string, mixed> $data, ArrayObject<string, mixed> $options): void
The Model.afterMarshal event is fired after request data is converted into entities. Event handlers will get the converted entities, original request data and the options provided to the patchEntity() or newEntity() call.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\Datasource\EntityInterface$entity The entity to be saved.
-
ArrayObject<string, mixed>$data Data to be saved.
-
ArrayObject<string, mixed>$options Options.
Returns
voidafterRules() ¶ public
afterRules(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\Datasource\EntityInterface $entity, ArrayObject<string, mixed> $options, bool $result, string $operation): void
The Model.afterRules event is fired after an entity has rules applied. By stopping this event, you can return the final value of the rules checking operation.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\Datasource\EntityInterface$entity The entity to be saved.
-
ArrayObject<string, mixed>$options Options.
-
bool$result Result.
-
string$operation Operation.
Returns
voidafterSave() ¶ public
afterSave(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\Datasource\EntityInterface $entity, ArrayObject<string, mixed> $options): void
The Model.afterSave event is fired after an entity is saved.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\Datasource\EntityInterface$entity Saved entity.
-
ArrayObject<string, mixed>$options Options.
Returns
voidafterSaveCommit() ¶ public
afterSaveCommit(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\Datasource\EntityInterface $entity, ArrayObject<string, mixed> $options): void
The Model.afterSaveCommit event is fired after the transaction in which the save operation is wrapped has been committed. It’s also triggered for non atomic saves where database operations are implicitly committed. The event is triggered only for the primary table on which save() is directly called. The event is not triggered if a transaction is started before calling save.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\Datasource\EntityInterface$entity Saved entity.
-
ArrayObject<string, mixed>$options Options.
Returns
voidbeforeDelete() ¶ public
beforeDelete(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\Datasource\EntityInterface $entity, ArrayObject<string, mixed> $options): void
The Model.beforeDelete event is fired before an entity is deleted. By stopping this event you will abort the delete operation. When the event is stopped the result of the event will be returned.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\Datasource\EntityInterface$entity Entity to be deleted.
-
ArrayObject<string, mixed>$options Options.
Returns
voidbeforeFind() ¶ public
beforeFind(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\ORM\Query\SelectQuery $query, ArrayObject<string, mixed> $options, bool $primary): void
The Model.beforeFind event is fired before each find operation.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\ORM\Query\SelectQuery$query Query.
-
ArrayObject<string, mixed>$options Options.
-
bool$primary trueif it is the root query,falseif it is the associated query.
Returns
voidbeforeMarshal() ¶ public
beforeMarshal(Cake\Event\EventInterface<Cake\ORM\Table> $event, ArrayObject<string, mixed> $data, ArrayObject<string, mixed> $options): void
The Model.beforeMarshal event is fired before request data is converted into entities.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
ArrayObject<string, mixed>$data Data to be saved.
-
ArrayObject<string, mixed>$options Options.
Returns
voidbeforeRules() ¶ public
beforeRules(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\Datasource\EntityInterface $entity, ArrayObject<string, mixed> $options, string $operation): void
The Model.beforeRules event is fired before an entity has had rules applied. By stopping this event, you can halt the rules checking and set the result of applying rules.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\Datasource\EntityInterface$entity The entity to be saved.
-
ArrayObject<string, mixed>$options Options.
-
string$operation Operation.
Returns
voidbeforeSave() ¶ public
beforeSave(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\Datasource\EntityInterface $entity, ArrayObject<string, mixed> $options): void
The Model.beforeSave event is fired before each entity is saved. Stopping this event will abort the save operation. When the event is stopped the result of the event will be returned.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\Datasource\EntityInterface$entity The entity to be saved.
-
ArrayObject<string, mixed>$options Options.
Returns
voidbuildValidator() ¶ public
buildValidator(Cake\Event\EventInterface<Cake\ORM\Table> $event, Cake\Validation\Validator $validator, string $name): void
The Model.buildValidator event is fired when $name validator is created. Behaviors, can use this hook to add in validation methods.
Parameters
-
Cake\Event\EventInterface<Cake\ORM\Table>$event Model event.
-
Cake\Validation\Validator$validator Validator.
-
string$name Name.
Returns
void