Skip to content

Commit

Permalink
Add more complete method signature.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 21, 2017
1 parent 0a06d92 commit 5d852f7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions en/orm/behaviors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ behavior should now look like::

namespace App\Model\Behavior;

use ArrayObject;
use Cake\Datasource\EntityInterface;
use Cake\Event\Event;
use Cake\ORM\Behavior;
Expand All @@ -170,7 +171,7 @@ behavior should now look like::
$entity->set($config['slug'], Text::slug($value, $config['replacement']));
}

public function beforeSave(Event $event, EntityInterface $entity)
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)
{
$this->slug($entity);
}
Expand All @@ -186,7 +187,7 @@ The above code shows a few interesting features of behaviors:

To prevent the saving from continuing simply stop event propagation in your callback::

public function beforeSave(Event $event, EntityInterface $entity)
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)
{
if (...) {
$event->stopPropagation();
Expand Down
5 changes: 3 additions & 2 deletions fr/orm/behaviors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ behavior devrait maintenant ressembler à ceci::

namespace App\Model\Behavior;

use ArrayObject;
use Cake\Datasource\EntityInterface;
use Cake\Event\Event;
use Cake\ORM\Behavior;
Expand All @@ -172,7 +173,7 @@ behavior devrait maintenant ressembler à ceci::
$entity->set($config['slug'], Text::slug($value, $config['replacement']));
}

public function beforeSave(Event $event, EntityInterface $entity)
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)
{
$this->slug($entity);
}
Expand All @@ -190,7 +191,7 @@ Le code ci-dessus montre quelques fonctionnalités intéressantes des behaviors:
Pour empêcher l'enregistrement de continuer, arrêtez simplement la propagation
de l'évènement dans votre callback::

public function beforeSave(Event $event, EntityInterface $entity)
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)
{
if (...) {
$event->stopPropagation();
Expand Down
5 changes: 3 additions & 2 deletions ja/orm/behaviors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ sluggable behavior を作成してみます。

namespace App\Model\Behavior;

use ArrayObject;
use Cake\Datasource\EntityInterface;
use Cake\Event\Event;
use Cake\ORM\Behavior;
Expand All @@ -157,7 +158,7 @@ sluggable behavior を作成してみます。
$entity->set($config['slug'], Text::slug($value, $config['replacement']));
}

public function beforeSave(Event $event, EntityInterface $entity)
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)
{
$this->slug($entity);
}
Expand All @@ -172,7 +173,7 @@ sluggable behavior を作成してみます。

保存が続行しないようにするには、コールバック内のイベント伝播を停止するだけです。 ::

public function beforeSave(Event $event, EntityInterface $entity)
public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)
{
if (...) {
$event->stopPropagation();
Expand Down
2 changes: 1 addition & 1 deletion pt/orm/behaviors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ Behaviors (Comportamentos)
/orm/behaviors/counter-cache
/orm/behaviors/timestamp
/orm/behaviors/translate
/orm/behaviors/tree
/orm/behaviors/tree

0 comments on commit 5d852f7

Please sign in to comment.