예제 #1
0
 /**
  * Returns an {@link EventCollection} instance created with the hooks from the `events` config.
  *
  * @param Core $app
  *
  * @return EventCollection
  */
 public static function get_events(Core $app)
 {
     static $events;
     if (!$events) {
         $events = new EventCollection($app->configs['event']);
         EventCollectionProvider::using(function () use($app) {
             return $app->events;
         });
     }
     return $events;
 }
예제 #2
0
파일: View.php 프로젝트: icanboogie/view
 /**
  * An event hook is attached to the `action` event of the controller for late rendering,
  * which only happens if the response is `null`.
  *
  * @param Controller $controller The controller that invoked the view.
  * @param Renderer $renderer
  */
 public function __construct(Controller $controller, Renderer $renderer)
 {
     $this->controller = $controller;
     $this->renderer = $renderer;
     $this['view'] = $this;
     EventCollectionProvider::provide()->attach_to($controller, function (Controller\ActionEvent $event, Controller $target) {
         $this->on_action($event);
     });
 }