Skip to content

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

@curtisgibby

Description

@curtisgibby

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions