/** * Подготовка данных для шаблона * @return $this */ public function run() { if (static::$isRegisteredAssets === false) { ShopAsset::register($this->getView()); $options = $this->clientOptions; $options = Json::encode($options); $this->getView()->registerJs(<<<JS (function(sx, \$, _) { sx.Shop = new sx.classes.shop.App({$options}); })(sx, sx.\$, sx._); JS ); static::$isRegisteredAssets = true; } return parent::run(); }
/** * Подготовка данных для шаблона * @return $this */ public function run() { if (static::$isRegisteredAssets === false) { ShopAsset::register($this->getView()); $options = (array) $this->clientOptions; $options['cartData'] = \Yii::$app->shop->shopFuser->jsonSerialize(); $options = Json::encode($options); $this->getView()->registerJs(<<<JS (function(sx, \$, _) { sx.Shop = new sx.classes.shop.App({$options}); })(sx, sx.\$, sx._); JS ); static::$isRegisteredAssets = true; } return parent::run(); }