/**
  * Bootstrap method to be called during application bootstrap stage.
  * @param Application $app the application currently running
  */
 public function bootstrap($app)
 {
     $this->buildModelMap();
     $app->on(Application::EVENT_AFTER_REQUEST, function () {
         $this->process();
     });
 }
Exemplo n.º 2
0
 /**
  * Hooks into the running Yii application by registering various event handlers.
  * Registers event handlers for searches in Big.
  * Is called at the end of the boostrapping process.
  *
  * @param yii\web\Application $app the application currently running.
  */
 public function registerApplicationHooks($app)
 {
     $app->getView()->on(View::EVENT_BEGIN_PAGE, function ($event) {
         // render blocks if the active theme has positions enabled
         $positions = $this->getActiveThemePositions();
         if (!empty($positions)) {
             $this->renderBlocks($positions);
         }
         // set the page title (if not set by a Block) when a layout starts to render.
         $view = $event->sender;
         $menu = $this->menuManager->getActive();
         if (empty($view->title) && $menu) {
             $view->title = empty($menu->meta_title) ? $menu->title : $menu->meta_title;
         }
     });
     if ($this->enableDynamicContent) {
         // register event handler that parses the application response
         $app->on(Application::EVENT_AFTER_REQUEST, [$this, 'parseResponse']);
     }
 }