コード例 #1
0
ファイル: Category.php プロジェクト: EhteshamMehmood/BlogMVC
 /**
  * Before-validation callback to automate slug generation even if it wasn't
  * handled on frontend.
  *
  * @return bool Operation success.
  * @since 0.1.0
  */
 public function beforeValidate()
 {
     if (!parent::beforeValidate()) {
         return false;
     }
     if (!empty($this->slug)) {
         $this->slug = \Yii::app()->formatter->slugify($this->slug);
     } elseif (!empty($this->name)) {
         $this->slug = \Yii::app()->formatter->slugify($this->name);
     }
     return true;
 }
コード例 #2
0
ファイル: Comment.php プロジェクト: DavBfr/BlogMVC
 /**
  * Sanitizes user mail before validation.
  *
  * @return boolean True if parent beforeValidate() fails, true otherwise.
  * @since 0.1.0
  */
 public function beforeValidate()
 {
     if (!parent::beforeValidate()) {
         return false;
     }
     $this->mail = trim(strtolower($this->mail));
     $this->content = strip_tags($this->content);
     if (!\Yii::app()->user->getIsGuest()) {
         $this->username = '******' . \Yii::app()->user->username;
     } else {
         $this->username = ltrim($this->username, '@');
     }
     return true;
 }