Пример #1
1
 /**
  * @throws \rmrevin\yii\minify\Exception
  */
 public function init()
 {
     parent::init();
     $minify_path = $this->minify_path = (string) \Yii::getAlias($this->minify_path);
     if (!file_exists($minify_path)) {
         helpers\FileHelper::createDirectory($minify_path);
     }
     if (!is_readable($minify_path)) {
         throw new Exception('Directory for compressed assets is not readable.');
     }
     if (!is_writable($minify_path)) {
         throw new Exception('Directory for compressed assets is not writable.');
     }
     if (true === $this->compress_output) {
         \Yii::$app->response->on(\yii\web\Response::EVENT_BEFORE_SEND, function (\yii\base\Event $Event) {
             /** @var \yii\web\Response $Response */
             $Response = $Event->sender;
             if ($Response->format === \yii\web\Response::FORMAT_HTML) {
                 if (!empty($Response->data)) {
                     $Response->data = HtmlCompressor::compress($Response->data, $this->compress_options);
                 }
                 if (!empty($Response->content)) {
                     $Response->content = HtmlCompressor::compress($Response->content, $this->compress_options);
                 }
             }
         });
     }
 }
Пример #2
0
 public function init()
 {
     parent::init();
     if (empty($this->defaultPath)) {
         $this->defaultPath[] = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'defaultViews');
     }
 }
Пример #3
0
 public function init()
 {
     parent::init();
     if (wanhunet::$app->getSession()->hasFlash('errors')) {
         $this->params['errors'] = wanhunet::$app->getSession()->getFlash('errors');
     }
 }
Пример #4
0
 public function init()
 {
     parent::init();
     if (is_string($this->viewElementsGathener)) {
         $this->viewElementsGathener = Yii::$app->get('viewElementsGathener');
     }
 }
Пример #5
0
 public function init()
 {
     parent::init();
     $this->modularityService = LuLu::getService('modularity');
     $this->rbacService = LuLu::getService('rbac');
     $this->taxonomyService = LuLu::getService('taxonomy');
 }
Пример #6
0
 /**
  * @throws \rmrevin\yii\minify\Exception
  */
 public function init()
 {
     parent::init();
     if (php_sapi_name() !== 'cli') {
         $urlDetails = \Yii::$app->urlManager->parseRequest(\Yii::$app->request);
         if (in_array($urlDetails[0], $this->exclude_routes)) {
             $this->enableMinify = false;
         }
     }
     $minify_path = $this->minify_path = (string) \Yii::getAlias($this->minify_path);
     if (!file_exists($minify_path)) {
         helpers\FileHelper::createDirectory($minify_path);
     }
     if (!is_readable($minify_path)) {
         throw new Exception('Directory for compressed assets is not readable.');
     }
     if (!is_writable($minify_path)) {
         throw new Exception('Directory for compressed assets is not writable.');
     }
     if (true === $this->compress_output) {
         \Yii::$app->response->on(\yii\web\Response::EVENT_BEFORE_SEND, function (\yii\base\Event $Event) {
             /** @var \yii\web\Response $Response */
             $Response = $Event->sender;
             if ($Response->format === \yii\web\Response::FORMAT_HTML) {
                 if (!empty($Response->data)) {
                     $Response->data = HtmlCompressor::compress($Response->data, ['extra' => true]);
                 }
                 if (!empty($Response->content)) {
                     $Response->content = HtmlCompressor::compress($Response->content, ['extra' => true]);
                 }
             }
         });
     }
 }
Пример #7
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->setDefaultSmartLoadConfig();
     if ($this->smartLoadConfig['disableNativeScriptFilter']) {
         $this->disableNativeScriptFilter();
     }
     $this->getRSmartLoad()->init();
 }
Пример #8
0
 public function init()
 {
     // call parent initializer
     parent::init();
     // auto register csrf tags if enabled
     if ($this->autoRegisterCsrf && Yii::$app->request->enableCsrfValidation) {
         $this->registerMetaTag(['name' => 'csrf-param', 'content' => Yii::$app->request->csrfParam], 'csrfParam');
         $this->registerMetaTag(['name' => 'csrf-token', 'content' => Yii::$app->request->getCsrfToken()], 'csrfToken');
     }
 }
Пример #9
0
 public function init()
 {
     parent::init();
     if ($this->channels == null) {
         $this->channels = CommonUtility::getCachedChannel();
     }
     if ($this->rootChannels == null) {
         $this->rootChannels = CommonUtility::getRootChannels();
     }
 }
Пример #10
0
 public function init()
 {
     parent::init();
     $minify_path = $this->minify_path = \Yii::getAlias($this->minify_path);
     if (!file_exists($minify_path)) {
         FileHelper::createDirectory($minify_path);
     }
     if (!is_readable($minify_path)) {
         throw new \RuntimeException(\Yii::t('app', 'Directory for compressed assets is not readable.'));
     }
     if (!is_writable($minify_path)) {
         throw new \RuntimeException(\Yii::t('app', 'Directory for compressed assets is not writable.'));
     }
 }
Пример #11
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->compress === true) {
         \Yii::$app->response->on(\yii\web\Response::EVENT_BEFORE_SEND, function (\yii\base\Event $Event) {
             $Response = $Event->sender;
             if ($Response->format === \yii\web\Response::FORMAT_HTML) {
                 if (!empty($Response->data)) {
                     $Response->data = self::compress($Response->data);
                 }
                 if (!empty($Response->content)) {
                     $Response->content = self::compress($Response->content);
                 }
             }
         });
     }
 }
Пример #12
0
 public function init()
 {
     parent::init();
     $this->on(self::EVENT_END_BODY, $this->getOgMetaTagsLoader());
     $this->on(self::EVENT_END_BODY, $this->getTwitterMetaTagsLoader());
 }
Пример #13
0
 /**
  * Ensures storage component is set.
  */
 public function init()
 {
     parent::init();
     $this->storage = Instance::ensure($this->storage, '\\ArrayAccess');
 }
Пример #14
0
 public function init()
 {
     parent::init();
     $this->publishPath = \Yii::getAlias($this->publishPath);
     $this->publishUrl = \Yii::getAlias($this->publishUrl);
 }
Пример #15
0
 public function init()
 {
     parent::init();
     $this->on(self::EVENT_BEGIN_PAGE, [$this, 'eventSetMeta']);
 }
Пример #16
0
 public function init()
 {
     parent::init();
     $this->registerJs('window.appName = ' . Json::encode(Yii::$app->name) . ';', View::POS_END);
     $this->registerJs('window[' . Json::encode(Yii::$app->name) . '] = {};', View::POS_END);
 }
Пример #17
0
 public function init()
 {
     parent::init();
     $this->initService();
 }
Пример #18
0
 public function init()
 {
     parent::init();
     $this->wpTheme = $this->theme;
 }
Пример #19
0
 /**
  * Set default page title.
  */
 public function init()
 {
     parent::init();
     $this->setTitle(\Yii::$app->name);
 }
Пример #20
0
 public function init()
 {
     parent::init();
 }