|
|
@ -8,6 +8,7 @@ |
|
|
|
namespace yii\web; |
|
|
|
namespace yii\web; |
|
|
|
|
|
|
|
|
|
|
|
use Yii; |
|
|
|
use Yii; |
|
|
|
|
|
|
|
use yii\base\View; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
|
* @author Qiang Xue <qiang.xue@gmail.com> |
|
|
@ -29,12 +30,12 @@ class YiiAsset extends AssetBundle |
|
|
|
public function registerAssets($view) |
|
|
|
public function registerAssets($view) |
|
|
|
{ |
|
|
|
{ |
|
|
|
parent::registerAssets($view); |
|
|
|
parent::registerAssets($view); |
|
|
|
$js[] = "yii.version = '" . Yii::getVersion() . "';"; |
|
|
|
$js[] = "yii.version='" . Yii::getVersion() . "';"; |
|
|
|
$request = Yii::$app->getRequest(); |
|
|
|
$request = Yii::$app->getRequest(); |
|
|
|
if ($request instanceof Request && $request->enableCsrfValidation) { |
|
|
|
if ($request instanceof Request && $request->enableCsrfValidation) { |
|
|
|
$js[] = "yii.csrfVar = '{$request->csrfVar}';"; |
|
|
|
$js[] = "yii.csrfVar='{$request->csrfVar}';"; |
|
|
|
$js[] = "yii.csrfToken = '{$request->csrfToken}';"; |
|
|
|
$js[] = "yii.csrfToken='{$request->csrfToken}';"; |
|
|
|
} |
|
|
|
} |
|
|
|
$view->registerJs(implode("\n", $js)); |
|
|
|
$view->registerJs(implode("\n", $js), View::POS_END); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|