Is it possible to use view helper in another view helper? We have to view helpers:
HelpMe1
use Zend\View\Helper\AbstractHelper;
class HelpMe1 extends AbstractHelper
{
public function __invoke($arg)
{
return $arg;
}
}
HelpMe2
use PathTo\HelpMe1;
use Zend\View\Helper\AbstractHelper;
class HelpMe2 extends AbstractHelper
{
public function __invoke()
{
return '<p>' . new HelpMe1('Text') . '</p>';
}
}
If this is possible what it the base practice for that?
Regards,
As long as your helper extends the abstract helper class, the View object is injected into it, and you can access other helpers from there.
class HelpMe2 extends AbstractHelper
{
public function __invoke()
{
return '<p>' . $this->view->helpMe1('Text') . '</p>';
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With