本文整理匯總了PHP中yii\web\View::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP View::init方法的具體用法?PHP View::init怎麽用?PHP View::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類yii\web\View
的用法示例。
在下文中一共展示了View::init方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
public function init()
{
parent::init();
if (empty($this->defaultPath)) {
$this->defaultPath[] = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'defaultViews');
}
}
示例2: init
/**
* @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);
}
}
});
}
}
示例3: init
public function init()
{
parent::init();
if (wanhunet::$app->getSession()->hasFlash('errors')) {
$this->params['errors'] = wanhunet::$app->getSession()->getFlash('errors');
}
}
示例4: init
public function init()
{
parent::init();
if (is_string($this->viewElementsGathener)) {
$this->viewElementsGathener = Yii::$app->get('viewElementsGathener');
}
}
示例5: init
public function init()
{
parent::init();
$this->modularityService = LuLu::getService('modularity');
$this->rbacService = LuLu::getService('rbac');
$this->taxonomyService = LuLu::getService('taxonomy');
}
示例6: init
/**
* @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: init
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->setDefaultSmartLoadConfig();
if ($this->smartLoadConfig['disableNativeScriptFilter']) {
$this->disableNativeScriptFilter();
}
$this->getRSmartLoad()->init();
}
示例8: init
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: init
public function init()
{
parent::init();
if ($this->channels == null) {
$this->channels = CommonUtility::getCachedChannel();
}
if ($this->rootChannels == null) {
$this->rootChannels = CommonUtility::getRootChannels();
}
}
示例10: init
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: init
/**
* @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: init
public function init()
{
parent::init();
$this->on(self::EVENT_END_BODY, $this->getOgMetaTagsLoader());
$this->on(self::EVENT_END_BODY, $this->getTwitterMetaTagsLoader());
}
示例13: init
/**
* Ensures storage component is set.
*/
public function init()
{
parent::init();
$this->storage = Instance::ensure($this->storage, '\\ArrayAccess');
}
示例14: init
public function init()
{
parent::init();
$this->publishPath = \Yii::getAlias($this->publishPath);
$this->publishUrl = \Yii::getAlias($this->publishUrl);
}
示例15: init
public function init()
{
parent::init();
$this->on(self::EVENT_BEGIN_PAGE, [$this, 'eventSetMeta']);
}