Skip to content

Instantly share code, notes, and snippets.

@robertbasic
Created July 27, 2011 18:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save robertbasic/1110033 to your computer and use it in GitHub Desktop.
Loading action helpers with the prefix path loader
<?php
class Bootstrap {
public function _initActionHelpers()
{
$this->bootstrap('FrontController');
$fc = $this->getResource('FrontController');
$fc->getHelperBroker()
->setClassLoader(new \Zend\Loader\PrefixPathLoader(
array(
array(
'prefix' => 'Zend\Controller\Action\Helper',
'path' => realpath(APPLICATION_PATH . '/../library/Zend/Controller/Action/Helper/')
),
array(
'prefix' => 'Planet\Controller\Helper',
'path' => realpath(APPLICATION_PATH . '/modules/public/controllers/helpers/')
)
)
)
);
@Thinkscape
Copy link

You need to supply the class loader at resource-loading time. I.e.

$application = new \Zend\Application(array(
'resources' => array('frontcontroller' => .. ............. )
));

@robertbasic
Copy link
Author

I just did this from the application.ini and it still works:

resources.frontcontroller.actionhelper.class = '\Zend\Controller\Action\HelperBroker'
resources.frontcontroller.actionhelper.class_loader.class = 'Zend\Loader\PrefixPathLoader'
resources.frontcontroller.actionhelper.class_loader.options.1.prefix = 'Zend\Controller\Action\Helper'
resources.frontcontroller.actionhelper.class_loader.options.1.path = APPLICATION_PATH '/../library/Zend/Controller/Action/Helper'
resources.frontcontroller.actionhelper.class_loader.options.2.prefix = 'Planet\Controller\Helper'
resources.frontcontroller.actionhelper.class_loader.options.2.path = APPLICATION_PATH '/modules/public/controllers/helpers'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment