Commit b2040b8e by Roman Khafizianov Committed by Alexander Makarov

Fixes #5178: undefined getGlobal('_viewRenderer') error if compile cache is used

parent 679c85a1
......@@ -148,9 +148,10 @@ class Extension
// Inject code to re-register widget tag during run-time
return <<<PHP
<?php
\$_smarty_tpl->getGlobal('_viewRenderer')->widgets['blocks']['$alias'] = '$class';
\$viewRenderer=\$_smarty_tpl->default_template_handler_func[0];
\$viewRenderer->widgets['blocks']['$alias'] = '$class';
try {
\$_smarty_tpl->registerPlugin('block', '$alias', [\$_smarty_tpl->getGlobal('_viewRenderer'), '_widget_block__$alias']);
\$_smarty_tpl->registerPlugin('block', '$alias', [\$viewRenderer, '_widget_block__$alias']);
}
catch (SmartyException \$e) {
/* Ignore already registered exception during first execution after compilation */
......@@ -165,9 +166,10 @@ PHP;
// Inject code to re-register widget tag during run-time
return <<<PHP
<?php
\$_smarty_tpl->getGlobal('_viewRenderer')->widgets['functions']['$alias'] = '$class';
\$viewRenderer=\$_smarty_tpl->default_template_handler_func[0];
\$viewRenderer->widgets['functions']['$alias'] = '$class';
try {
\$_smarty_tpl->registerPlugin('function', '$alias', [\$_smarty_tpl->getGlobal('_viewRenderer'), '_widget_function__$alias']);
\$_smarty_tpl->registerPlugin('function', '$alias', [\$viewRenderer, '_widget_function__$alias']);
}
catch (SmartyException \$e) {
/* Ignore already registered exception during first execution after compilation */
......@@ -319,10 +321,11 @@ PHP;
$url = ArrayHelper::remove($params, 'url');
$key = ArrayHelper::remove($params, 'key', null);
$depends = ArrayHelper::remove($params, 'depends', null);
if (isset($params['position']))
$params['position'] = $this->getViewConstVal($params['position'], View::POS_END);
Yii::$app->getView()->registerJsFile($url, $params, $key);
Yii::$app->getView()->registerJsFile($url, $depends, $params, $key);
}
/**
......@@ -378,8 +381,9 @@ PHP;
$url = ArrayHelper::remove($params, 'url');
$key = ArrayHelper::remove($params, 'key', null);
$depends = ArrayHelper::remove($params, 'depends', null);
Yii::$app->getView()->registerCssFile($url, $params, $key);
Yii::$app->getView()->registerCssFile($url, $depends, $params, $key);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment