Ejemplo n.º 1
0
 public function afterSave()
 {
     parent::afterSave();
     if (empty($this->url)) {
         $this->url = new Seo();
         $this->url->controller = "bookInfo";
         $this->url->action = "about";
         $this->url->item_id = $this->id;
         $url = UserFunctions::translit($this->author->name . "_" . $this->name);
         if (!is_null(Seo::model()->findByAttributes(array('url' => $url)))) {
             $url .= time();
         }
         $this->url->url = $url;
         if ($this->url->save()) {
             $this->seo_id = $this->url->id;
         }
         $this->save();
     }
 }