Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior #6

Open
bobmulder opened this issue Jul 10, 2015 · 3 comments
Open

Behavior #6

bobmulder opened this issue Jul 10, 2015 · 3 comments

Comments

@bobmulder
Copy link

Hey man,

Am I allowed to convert this awesome trait to a behavior for the Cake 3 Utils Plugin? It would be easier to implement, and could be documented at http://cakemanager.org/docs/utils/1.0/.

Greetz

Bob

@PGBI
Copy link
Owner

PGBI commented Jul 10, 2015

At first I had tried to write a behavior instead of a trait, but did not manage to do what I wanted.

With a behavior, you cannot override Model::delete(). So the way to do is to catch the beforeDelete event in the behavior, update the soft delete field, and then stop the propagation of the event to avoid the hard deletion to happen. But by doing so, you prevent the cascade deletion to other models as well as counter cache updates, which I think was not satisfactory.

But if you find a way to make all this work with a behavior, feel free to convert it!

@bobmulder
Copy link
Author

I will try to find a way but thank's for your information.

@bobmulder
Copy link
Author

For now I see no solution to override the delete()-method. What do you think about implementing this trait into the Utils-plugin to make it easier to use (because you got a big library)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants