Exemplo n.º 1
0
 /**
  * offsetSet()
  *
  * @param int $priority
  * @param Zend_Controller_Action_Helper_Abstract $helper
  * @return Zend_Controller_Action_HelperBroker_PriorityStack
  */
 public function offsetSet($priority, $helper)
 {
     $priority = (int) $priority;
     if (!$helper instanceof Zend_Controller_Action_Helper_Abstract) {
         #require_once 'Zend/Controller/Action/Exception.php';
         throw new Zend_Controller_Action_Exception('$helper must extend Zend_Controller_Action_Helper_Abstract.');
     }
     if (array_key_exists($helper->getName(), $this->_helpersByNameRef)) {
         // remove any object with the same name to retain BC compailitbility
         // @todo At ZF 2.0 time throw an exception here.
         $this->offsetUnset($helper->getName());
     }
     if (array_key_exists($priority, $this->_helpersByPriority)) {
         $priority = $this->getNextFreeHigherPriority($priority);
         // ensures LIFO
         trigger_error("A helper with the same priority already exists, reassigning to {$priority}", E_USER_WARNING);
     }
     $this->_helpersByPriority[$priority] = $helper;
     $this->_helpersByNameRef[$helper->getName()] = $helper;
     if ($priority == ($nextFreeDefault = $this->getNextFreeHigherPriority($this->_nextDefaultPriority))) {
         $this->_nextDefaultPriority = $nextFreeDefault;
     }
     krsort($this->_helpersByPriority);
     // always make sure priority and LIFO are both enforced
     return $this;
 }
Exemplo n.º 2
0
 /**
  * addHelper() - Add helper objects
  *
  * @param Zend_Controller_Action_Helper_Abstract $helper
  * @return void
  */
 public static function addHelper(Zend_Controller_Action_Helper_Abstract $helper)
 {
     $helper_name = $helper->getName();
     self::$_helpers[$helper_name] = $helper;
     return;
 }
 /**
  * Retrieve name that identify this helper class
  *
  * @return string
  */
 public function getName()
 {
     $name = parent::getName();
     return 'Configurator_' . $name;
 }
 /**
  * Adds the given action  helper to the broker.
  *
  * @param Zend_Controller_Action_Helper_Abstract $helper
  */
 protected function addActionHelper(Zend_Controller_Action_Helper_Abstract $helper)
 {
     $this->helpersToRemove[] = $helper->getName();
     Zend_Controller_Action_HelperBroker::addHelper($helper);
     $message = 'Helper "' . $helper->getName() . '" was not added.';
     $this->assertTrue(Zend_Controller_Action_HelperBroker::hasHelper($helper->getName()), $message);
 }