コード例 #1
0
 public function afterRenderView(Event $event, View $view)
 {
     if ('afterRenderView' == $event->getType()) {
         $this->levels[] = $view->getCurrentRenderLevel();
     }
     return true;
 }
コード例 #2
0
ファイル: Security.php プロジェクト: nhannhan159/T4Logs
 /**
  * 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;
 }
コード例 #3
0
ファイル: Initializer.php プロジェクト: biggtfish/cms
 /**
  * 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();
 }
コード例 #4
0
 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());
 }