/** * * @param string $result * @param Context $context * * @return array Rule array or false if not found */ protected function find($result, Context $context) { $actionName = $context->getActionName(); if ($context->getRequest()->isXmlHttpRequest() && isset($this->rules[$actionName]['ajax:' . $result])) { return $this->rules[$actionName]['ajax:' . $result]; } elseif ($context->hasParent() && isset($this->rules[$actionName]['embed:' . $result])) { return $this->rules[$actionName]['embed:' . $result]; } return isset($this->rules[$actionName][$result]) ? $this->rules[$actionName][$result] : false; }
/** * * @param Context $context * * @return mixed */ public function runAction(Context $context) { if (!$context->isReady()) { throw new Exception('Context is not ready (i.e. no action defined)'); } if (!$this->exists($context->getActionName())) { throw new Exception('Unregistered action "' . $context->getActionName() . '"'); } $proxy = $this->get($context->getActionName()); $this->notify(new BeforeActionEvent($proxy, $this, $context)); if ($context->isDone()) { return $context->getResult(); } $result = $proxy->execute($this, $context); $context->setResult($result); $this->notify(new AfterActionEvent($proxy, $this, $context)); return $result; }