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

Component doesn't check model behaviors' methods or mapped methods #22

Open
curtisgibby opened this issue Nov 13, 2014 · 0 comments
Open

Comments

@curtisgibby
Copy link
Contributor

In FilterComponent::beforeRender, when there's a selector specified, you check to see if a model has the specified method...

if (!method_exists($workingModel, $settings['selector']))
{
// trigger the error

... and if it doesn't, you trigger an error.

This doesn't take into account if the model has access to the selector method through a behavior, either explicitly declared in the behavior or through a magic "mapMethod." Adding a check against the model's BehaviorCollection->hasMethod resolves this problem.

if (
    ! method_exists($workingModel, $settings['selector']) &&
    ! $workingModel->Behaviors->hasMethod($settings['selector'])
)
{
// now you can trigger that error
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

No branches or pull requests

1 participant