public function afterRenderView(Event $event, View $view) { if ('afterRenderView' == $event->getType()) { $this->levels[] = $view->getCurrentRenderLevel(); } return true; }
/** * Triggered before the dispatcher throws any exception */ public function beforeException(Event $event, Dispatcher $dispatcher, $exception) { echo 'testing'; // Handle 404 exceptions if ($exception instanceof DispatchException) { $dispatcher->forward(array('controller' => 'quick-response', 'action' => 'sendNotFoundStatus')); return false; } // Alternative way, controller or action doesn't exist if ($event->getType() == 'beforeException') { switch ($exception->getCode()) { case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND: case Dispatcher::EXCEPTION_ACTION_NOT_FOUND: $dispatcher->forward(array('controller' => 'quick-response', 'action' => 'sendNotFoundStatus')); return false; } } return true; }
/** * This is called after initialize the model. * * @param Event $event Event object. * @param ModelsManager $manager Model manager * @param AbstractModel $model Model object. * * @return string */ public function afterInitialize(Event $event, ModelsManager $manager, $model) { //Reflector $reflector = $this->annotations->get($model); /** * Read the annotations in the class' docblock */ $annotations = $reflector->getClassAnnotations(); if ($annotations) { /** * Traverse the annotations */ foreach ($annotations as $annotation) { switch ($annotation->getName()) { /** * Initializes the model's source */ case 'Source': $arguments = $annotation->getArguments(); $manager->setModelSource($model, $arguments[0]); break; /** * Initializes Has-Many relations */ /** * Initializes Has-Many relations */ case 'HasMany': $arguments = $annotation->getArguments(); if (isset($arguments[3])) { $manager->addHasMany($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]); } else { $manager->addHasMany($model, $arguments[0], $arguments[1], $arguments[2]); } break; /** * Initializes BelongsTo relations */ /** * Initializes BelongsTo relations */ case 'BelongsTo': $arguments = $annotation->getArguments(); if (isset($arguments[3])) { $manager->addBelongsTo($model, $arguments[0], $arguments[1], $arguments[2], $arguments[3]); } else { $manager->addBelongsTo($model, $arguments[0], $arguments[1], $arguments[2]); } break; } } } return $event->getType(); }
public function handle(\Phalcon\Events\Event $oEvent, \Phalcon\Mvc\Dispatcher $oDispatcher) { $oLogger = $this->di->get('fileLogger'); $oLogger->info($oEvent->getType() . ' happened in ' . $oDispatcher->getControllerClass() . '::' . $oDispatcher->getActionName()); }