Example #1
0
 /**
  *
  * @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;
 }