Skip to content

Conversation

@cleptric
Copy link
Member

I added an example on how to stop the event, as I saw/got that question a few times lately.

stopping this event you will abort the delete operation.
stopping this event you will abort the delete operation. When the event is stopped the result
of the event will be returned.
Stopping the event works like this::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we link to the relevant section in the events docs instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could be an option, too. It would be this link, right? https://book.cakephp.org/3.0/en/core-libraries/events.html#stopping-events
I hope it's obvious how to call it than 😀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that looks like a good place to link to.


public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $options)
{
...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// ...

Just for the lazyp people copying stuff 1:1 😆

{
...
$event->stopPropagation();
...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@markstory markstory merged commit f1bcc1c into 3.0 Jul 25, 2017
@markstory markstory deleted the stopping-events branch July 25, 2017 17:51
okinaka added a commit to okinaka/docs that referenced this pull request Jul 26, 2017
chinpei215 added a commit that referenced this pull request Jul 27, 2017
HavokInspiration added a commit that referenced this pull request Jul 29, 2017
@HavokInspiration HavokInspiration added this to the 3.x milestone Jul 29, 2017
antograssiot added a commit that referenced this pull request Jul 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants