Created
July 23, 2011 08:47
-
-
Save robertbasic/1101201 to your computer and use it in GitHub Desktop.
ZF2 loading plugins and 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 | |
// telling ZF where an action helper is | |
class Bootstrap extends Application\Bootstrap { | |
public function _initActionHelpers() | |
{ | |
Zend\Loader\PluginClassLoader::addStaticMap(array('loggedinuser' => 'Planet\Controller\Helper\LoggedInUser')); | |
} | |
// registering FC plugins can be done like this | |
// or simply add resources.frontcontroller.plugins.admin = "PPN\Plugin\AdminContext" to application.ini | |
public function _initFcPlugins() | |
{ | |
$this->bootstrap('FrontController'); | |
$fc = $this->getResource('FrontController'); | |
$plugin = new PPN\Plugin\AdminContext(); | |
$fc->registerPlugin($plugin); | |
} |
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 IndexController extends Action | |
{ | |
public function init() | |
{ | |
// some AHs are pre-aliased, see Zend\Controller\Action\HelperLoader | |
$this->fm = $this->broker('flashmessenger'); | |
// accessing an AH which was aliased in the Bootstrap | |
$this->loggedInUser = $this->broker('loggedinuser'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment