/** * @inheritdoc */ public function beforeSave($insert) { /* author */ if ($insert) { $this->created_by = Yii::$app->user->id; } /* slug */ if (empty($this->slug)) { $this->slug = Core::generateSeoName($this->title); } /* published_at */ if ($this->status == Blog::STATUS_PUBLISHED && empty($this->published_at)) { $this->published_at = time(); } /* clean html */ $config = ['HTML.MaxImgLength' => null, 'CSS.MaxImgLength' => null, 'HTML.Trusted' => true, 'Filter.YouTube' => true]; $this->content = HtmlPurifier::process($this->content, $config); /* done */ return parent::beforeSave($insert); }
/** * @inheritdoc * @param bool $insert * @return bool */ public function beforeSave($insert) { if ($insert) { $this->setPassword(); $this->generateAuthKey(); /* default timezone and language */ $this->language = empty($this->language) ? Yii::$app->language : $this->language; $this->status = self::STATUS_ACTIVE; $this->timezone = empty($this->timezone) ? Yii::$app->timeZone : $this->timezone; } $this->seo_name = Core::generateSeoName($this->fullname); return parent::beforeSave($insert); }