Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Allow view helpers to be simple callables #60

Closed
wants to merge 1 commit into from
Closed

Allow view helpers to be simple callables #60

wants to merge 1 commit into from

Conversation

DASPRiD
Copy link
Member

@DASPRiD DASPRiD commented May 6, 2016

Currently, the user is forced to implement a setView() and getView() method in his view helpers, even though he's mostly likely not going to use them. This PR solves this by simply allowing any callable as a view helper. Extending classes can still specify a specific interface or class to check for, but the primary helper plugin manager now accepts any callable. This should be no BC break, but @weierophinney probably knows best.

@weierophinney weierophinney added this to the 2.7.0 milestone May 11, 2016
@weierophinney weierophinney self-assigned this May 11, 2016
$instanceOf = Helper\HelperInterface::class;
} else {
$instanceOf = $this->instanceOf;
}
Copy link
Member

Choose a reason for hiding this comment

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

We can make this simpler by removing the $instanceOf property entirely. The logic then becomes:

public function validate($instance)
{
    if (is_callable($instance) || $instance instanceof Helper\HelperInterface) {
       return;
    }
    // throw exception
}

I can do that on merge.

weierophinney added a commit that referenced this pull request May 12, 2016
Allow view helpers to be simple callables
weierophinney added a commit that referenced this pull request May 12, 2016
weierophinney added a commit that referenced this pull request May 12, 2016
@weierophinney
Copy link
Member

Merged to develop for release with 2.7.0.

(This loosens the types allowed, making it BC.)

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

Successfully merging this pull request may close these issues.

2 participants