Skip to content

Commit

Permalink
Improve / fix docblock info regarding model callbacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Sep 5, 2014
1 parent a2b1d4a commit 23f3aec
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 28 deletions.
32 changes: 17 additions & 15 deletions src/ORM/Behavior.php
Expand Up @@ -14,8 +14,8 @@
*/
namespace Cake\ORM;

use Cake\Core\InstanceConfigTrait;
use Cake\Core\Exception\Exception;
use Cake\Core\InstanceConfigTrait;
use Cake\Event\EventListener;

/**
Expand Down Expand Up @@ -46,24 +46,26 @@
* CakePHP provides a number of lifecycle events your behaviors can
* listen to:
*
* - `beforeFind(Event $event, Query $query)`
* Fired before a query is converted into SQL.
* - `beforeFind(Event $event, Query $query, ArrayObject $options, boolean $primary)`
* Fired before each find operation. By stopping the event and supplying a
* return value you can bypass the find operation entirely. Any changes done
* to the $query instance will be retained for the rest of the find. The
* $primary parameter indicates whether or not this is the root query,
* or an associated query.
*
* - `beforeDelete(Event $event, Entity $entity)`
* Fired before an entity is deleted.
* - `beforeSave(Event $event, Entity $entity, ArrayObject $options)`
* 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.
*
* - `afterDelete(Event $event, Entity $entity)`
* Fired after an entity has been deleted. The entity parameter
* will contain the entity state from before it was deleted.
* - `afterSave(Event $event, Entity $entity, ArrayObject $options)`
* Fired after an entity is saved.
*
* - `beforeSave(Event $event, Entity $entity)`
* Fired before an entity is saved. In the case where
* multiple entities are being saved, one event will be fired
* for each entity.
* - `beforeDelete(Event $event, Entity $entity, ArrayObject $options)`
* Fired before an entity is deleted. By stopping this event you will abort
* the delete operation.
*
* - `afterSave(Event $event, Entity $entity)`
* Fired after an entity is saved. The saved entity will be provided
* as a parameter.
* - `afterDelete(Event $event, Entity $entity, ArrayObject $options)`
* Fired after an entity has been deleted.
*
* In addition to the core events, behaviors can respond to any
* event fired from your Table classes including custom application
Expand Down
40 changes: 27 additions & 13 deletions src/ORM/Table.php
Expand Up @@ -75,19 +75,33 @@
* Table objects provide a few callbacks/events you can hook into to augment/replace
* find operations. Each event uses the standard event subsystem in CakePHP
*
* - `beforeFind($event, $query, $options, $eagerLoaded)` - Fired before each find operation.
* By stopping the event and supplying a return value you can bypass the find operation
* entirely. Any changes done to the $query instance will be retained for the rest of the find.
* - `beforeValidate($event, $entity, $options, $validator)` - Fired before an entity is validated.
* By stopping this event, you can abort the validate + save operations.
* - `afterValidate($event, $entity, $options, $validator)` - Fired after an entity is validated.
* - `beforeSave($event, $entity, $options)` - 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.
* - `afterSave($event, $entity, $options)` - Fired after an entity is saved.
* - `beforeDelete($event, $entity, $options)` - Fired before an entity is deleted.
* By stopping this event you will abort the delete operation.
* - `afterDelete($event, $entity, $options)` - Fired after an entity has been deleted.
* - `beforeFind(Event $event, Query $query, ArrayObject $options, boolean $primary)`
* Fired before each find operation. By stopping the event and supplying a
* return value you can bypass the find operation entirely. Any changes done
* to the $query instance will be retained for the rest of the find. The
* $primary parameter indicates whether or not this is the root query,
* or an associated query.
*
* - `beforeValidate(Event $event, Entity $entity, ArrayObject $options, Validator $validator)`
* Fired before an entity is validated. By stopping this event, you can abort
* the validate + save operations.
*
* - `afterValidate(Event $event, Entity $entity, ArrayObject $options, Validator $validator)`
* Fired after an entity is validated.
*
* - `beforeSave(Event $event, Entity $entity, ArrayObject $options)`
* 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.
*
* - `afterSave(Event $event, Entity $entity, ArrayObject $options)`
* Fired after an entity is saved.
*
* - `beforeDelete(Event $event, Entity $entity, ArrayObject $options)`
* Fired before an entity is deleted. By stopping this event you will abort
* the delete operation.
*
* - `afterDelete(Event $event, Entity $entity, ArrayObject $options)`
* Fired after an entity has been deleted.
*
* @see \Cake\Event\EventManager for reference on the events system.
*/
Expand Down

0 comments on commit 23f3aec

Please sign in to comment.