diff -r 000000000000 -r 4eba9c11703f web/Zend/Tool/Framework/Action/Repository.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/Tool/Framework/Action/Repository.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,138 @@ +_registry = $registry; + } + + /** + * addAction() + * + * @param Zend_Tool_Framework_Action_Interface $action + * @return Zend_Tool_Framework_Action_Repository + */ + public function addAction(Zend_Tool_Framework_Action_Interface $action, $overrideExistingAction = false) + { + $actionName = $action->getName(); + + if ($actionName == '' || $actionName == 'Base') { + require_once 'Zend/Tool/Framework/Action/Exception.php'; + throw new Zend_Tool_Framework_Action_Exception('An action name for the provided action could not be determined.'); + } + + if (!$overrideExistingAction && array_key_exists(strtolower($actionName), $this->_actions)) { + require_once 'Zend/Tool/Framework/Action/Exception.php'; + throw new Zend_Tool_Framework_Action_Exception('An action by the name ' . $actionName + . ' is already registered and $overrideExistingAction is set to false.'); + } + + $this->_actions[strtolower($actionName)] = $action; + return $this; + } + + /** + * process() - this is called when the client is done constructing (after init()) + * + * @return unknown + */ + public function process() + { + return null; + } + + /** + * getActions() - get all actions in the repository + * + * @return array + */ + public function getActions() + { + return $this->_actions; + } + + /** + * getAction() - get an action by a specific name + * + * @param string $actionName + * @return Zend_Tool_Framework_Action_Interface + */ + public function getAction($actionName) + { + if (!array_key_exists(strtolower($actionName), $this->_actions)) { + return null; + } + + return $this->_actions[strtolower($actionName)]; + } + + /** + * count() required by the Countable interface + * + * @return int + */ + public function count() + { + return count($this->_actions); + } + + /** + * getIterator() - get all actions, this supports the IteratorAggregate interface + * + * @return array + */ + public function getIterator() + { + return new ArrayIterator($this->_actions); + } + +}