public
Created

Another way of loading ZF2 action helpers

  • Download Gist
Bootstrap.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?php
class Bootstrap extends Application\Bootstrap {
/**
* Initializing action helpers
*/
public function _initActionHelpers()
{
// instead of this...
// Zend\Loader\PluginClassLoader::addStaticMap(array('loggedinuser' => 'Planet\Controller\Helper\LoggedInUser'));
// we can use this...
$this->bootstrap('FrontController');
$fc = $this->getResource('FrontController');
// but this isn't really lazy-loading, right?
$helper = new Planet\Controller\Helper\LoggedInUser();
$fc->getHelperBroker()->register('loggedinuser', $helper);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.