All pastes #550904 Raw Edit

Someone

public php v1 · immutable
·published 2007-06-08 15:52 UTC
rendered paste body
<?php/** * HelperAssign.php *  * @category   Naneau * @package    Naneau_Action_Helper * @copyright  Copyright (c) 2007 Maurice Fonk - http://naneau.nl * @version    0.1 *//** * action helper base class */require_once 'Zend/Controller/Action/Helper/Abstract.php';/** * Naneau_Action_Helper_HelperAssign *  * Small helper to assign all helpers to controllers for direct access * * @category   Naneau * @package    Naneau_Action_Helper * @copyright  Copyright (c) 2007 Maurice Fonk - http://naneau.nl */class Naneau_Action_Helper_HelperAssign extends Zend_Controller_Action_Helper_Abstract {    /**     * use underscore?     *      * Using underscores is the proper way of doing it, given the coding     * standard for the Zend Framework.     *     * @var bool     */    private $_useUnderscore = true;        private $_plugins;        public function preDispatch() {        $controller = $this->getActionController();                foreach (Zend_Controller_Action_HelperBroker::getExistingHelpers() as $helper) {            $name = $helper->getName();            if ($name != 'HelperAssign') {                $this->assign($name, $helper);            }        }                $controller = $this->getActionController();        foreach($this->_plugins as $name => $plugin) {            $controller->$name = $plugin;        }    }        public function assign($name, $class)    {        if ($this->_useUnderscore) {            $name = ltrim($name, '_');        }                if (! array_key_exists($name, $this->_plugins)) {            $this->_plugins[$name] = $class;        }    }}