Another way of loading ZF2 action helpers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
// this is better... | |
$fc->getHelperBroker()->getClassLoader()->registerPlugin('loggedinuser', 'Planet\Controller\Helper\LoggedInUser'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment