/** * @return object * @throws \yii\base\InvalidConfigException */ protected static function getSession() { if (is_null(static::$session)) { static::$session = Instance::ensure(static::$session, Session::className()); } return static::$session; }
/** * @inheritdoc */ public function init() { parent::init(); if ($this->session === null) { if (Yii::$app->has('session')) { $this->session = Yii::$app->get('session'); } } else { $this->session = Instance::ensure($this->session, Session::className()); } }
/** * Saves cart to the session */ public function saveToSession() { $this->session = Instance::ensure($this->session, Session::className()); $this->session[$this->cartId] = $this->getSerialized(); }