public function handle(IEvent $event)
 {
     $request = $event->getParameter('request');
     $route = $this->router->fetchRoute($request->getPathInfo());
     $event->setValue($route);
     return $route !== false;
 }
Exemplo n.º 2
0
 public function onStorageError(IEvent &$oEvent, $args = null)
 {
     //  Le document xml n'existe pas, on en crée un tout neuf
     $xml =& new xmlDocument('caddies');
     $xml->toFile($oEvent->getSource()->getDriver()->getFilepath());
     $oEvent->getSource()->setResource($xml);
 }
 /**
  * @param IEvent $event
  * @throws NotFoundEntityException
  */
 public function publish(IEvent $event)
 {
     $parent = EventHolder::get()->first();
     if (!$parent) {
         throw new NotFoundEntityException('EventHolder', '');
     }
     $event->setParent($parent);
     // Should set the ID once the Holder is created...
 }
 /**
  * Notifies all listeners of event name, unit the callable returns $state,
  * or the $event is set to handled.
  *
  * @param IEvent $event
  * @param mixed $state
  * @return IEvent
  */
 public function notifyUntil(IEvent $event, $state = true)
 {
     foreach ($this->getListeners($event->getName()) as $callable) {
         $result = $this->emitEvent($event, $callable);
         if ($result === $state || $event->isHandled()) {
             $event->setHandled(true);
             break;
         }
     }
     return $event;
 }
 public function handle(IEvent $event)
 {
     $route = $event->getParameter('route');
     $controller = $event->getParameter('controller');
     if (!$this->invoker->canInvoke($controller, $route)) {
         return false;
     }
     $result = $this->invoker->invoke($controller, $route);
     $event->setValue($result);
     return true;
 }
 public function handle(IEvent $event)
 {
     $route = $event->getParameter('route');
     $controller = $this->loader->loadController($route);
     if ($controller) {
         $event->setValue($controller);
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 7
0
 /**
  * @param IEvent $event
  * @return array
  */
 public static function convertEventToArray(IEvent $event)
 {
     $res = array();
     $main_info = $event->getMainInfo();
     $res['title'] = $main_info->getTitle();
     $res['url'] = $main_info->getUrl();
     $res['label'] = $main_info->getLabel();
     $res['category'] = $main_info->getCategory();
     $res['location'] = $event->getLocation();
     $duration = $event->getDuration();
     $res['start_date'] = $duration->getStartDate()->format('Y-m-d');
     $res['end_date'] = $duration->getEndDate()->format('Y-m-d');
     return $res;
 }
 public function handle(IEvent $event)
 {
     $presenter = $event->getParameter('presenter');
     $route = $event->getParameter('route');
     $paths = $this->paths->getPaths($route->getPackage() . '.views');
     foreach ($paths as $path) {
         $filename = $path . '/' . $presenter->getViewName() . $this->defaultExt;
         if (file_exists($filename)) {
             $rendered = $presenter->getOriginalResponse();
             $rendered->setContent($this->renderView($filename, $presenter->getVariables()));
             $event->setValue($rendered);
             return true;
         }
     }
     return false;
 }
 public function handle(IEvent $event)
 {
     $presenter = $event->getParameter('presenter');
     $viewname = $presenter->getViewName() . $this->defaultExtension;
     $variables = $presenter->getVariables();
     try {
         $template = $this->twig->loadTemplate($viewname);
     } catch (RuntimeException $e) {
         // do not fail when template couldn't be found
         if (strpos($e->getMessage(), 'Unable to find template') === 0) {
             return false;
         }
         throw $e;
     }
     $content = $template->render($presenter->getVariables());
     $response = $presenter->getOriginalResponse();
     $response->write($content);
     $event->setValue($response);
     return true;
 }
Exemplo n.º 10
0
 protected function _defaultBehaviour(IEvent $e)
 {
     $msg = '[' . get_class($e->getSource()) . '->' . $e->getName() . '] ' . trim((string) $e->getContext());
     $this->_log->write($msg);
     echo $msg . System::crlf;
 }
 public function handleControllerView(IEvent $e)
 {
     $presenter = $e->getParameter('presenter');
     $response = $presenter->getOriginalResponse();
     $variables = $presenter->getVariables();
     $response->setContent($variables['parameter']);
     $e->setValue($response);
     return true;
 }
Exemplo n.º 12
0
 public function onTimeout(IEvent &$e, $args = null)
 {
     $e->getSource()->getServer()->removeClient($this);
     $e =& new Event('controlTimeout', $this, $e->getContext());
     $this->dispatch($e);
 }