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
Easier Access to Helpers within Helpers #1021
Comments
I'm fine with short-hand, but I'd be pretty wary of putting a |
I'm mostly looking for consistency. If we added a |
If you extend helpers you can also use |
The more important question is -- how do you use a helper in a controller? |
@mpiasta-ca To me, that's outside the scope of what Controllers are intended for. I do my best to keep that sort of logic in the Views. Actually, I can't think of a case where I'd want to use a Helper in my Controllers. I agree with @nateabele, adding a |
Maybe you could declare the helpers you want to use in a protected property, and |
I like that solution @nateabele, kind of follows the |
I think |
@minhna I was aiming for consistency. Remember the each place for |
I'm with @minhna on this topic. |
Within views you can access a helper via
$this->name
but within a helper you cannot access another one the same way but you can do it via$this->_context->helper('name')
.When is it useful? A good use case is a
breadcrumb
helper. Here, you might need theRoute
helper or aString
orHtml
helper. AnAsset
helper might need thehtml
helper. There are dozens of other possible reasons to need them.Would anybody be up for a similar syntax in helpers? I assume the pr wouldn't be difficult.
The text was updated successfully, but these errors were encountered: