* @since 2.0 */ class YiiAsset extends AssetBundle { public $sourcePath = '@yii/assets'; public $js = array( 'yii.js', ); public $depends = array( 'yii\web\JqueryAsset', ); /** * @inheritdoc */ public function registerAssets($view) { parent::registerAssets($view); $js[] = "yii.version = '" . Yii::getVersion() . "';"; $request = Yii::$app->getRequest(); if ($request instanceof Request && $request->enableCsrfValidation) { $js[] = "yii.csrfVar = '{$request->csrfVar}';"; $js[] = "yii.csrfToken = '{$request->csrfToken}';"; } $view->registerJs(implode("\n", $js)); } }