Ejemplo n.º 1
0
 public function beforeSave($insert)
 {
     $redirectLink = new Redirect(['from' => $this->fullLink]);
     if (!$this->link) {
         $this->link = TranslitHelper::to($this->title);
     }
     if ($this->isAttributeChanged('parent') || $this->isAttributeChanged('link')) {
         $this->fullLink = '';
         if ($parent = $this->getParentCategory()) {
             $linkParts = [$parent->link];
             while ($parent = $parent->getParentCategory()) {
                 $linkParts[] = $parent->getRelativeLink();
             }
             $this->fullLink = implode('/', $linkParts) . '/';
         }
         $this->fullLink .= $this->link;
         if ($childs = $this->getChildCategories()) {
             foreach ($childs as $childCategory) {
                 $childCategory->fullLink = $this->fullLink . '/' . $childCategory->link;
                 $childCategory->save(false);
             }
         }
         $redirectLink->to = $this->fullLink;
     }
     if ($redirectLink->to) {
         $redirectLink->save();
     }
     return parent::beforeSave($insert);
     // TODO: Change the autogenerated stub
 }
Ejemplo n.º 2
0
 public function beforeSave($insert)
 {
     if (!$this->alias) {
         $this->alias = TranslitHelper::to($this->name);
     }
     return parent::beforeSave($insert);
     // TODO: Change the autogenerated stub
 }
Ejemplo n.º 3
0
 public function beforeSave($insert)
 {
     $this->params = Json::encode($this->params);
     $this->categories = Json::encode($this->categories);
     $this->articles = Json::encode($this->articles);
     if ($this->isNewRecord) {
         $this->created = date('Y-m-d H:i:s');
     }
     if (empty($this->link)) {
         $this->link = TranslitHelper::to($this->name);
     }
     return parent::beforeSave($insert);
 }
Ejemplo n.º 4
0
 public function beforeSave($insert)
 {
     if (empty($this->link)) {
         $this->link = TranslitHelper::to($this->name);
     }
     if (!preg_match('/^(\\w{0,7}:\\/\\/|\\/)/', $this->link)) {
         $this->link = '/' . $this->link;
     }
     if (empty($this->linkType)) {
         $this->linkType = self::LINK_TYPE_LINK;
     }
     return parent::beforeSave($insert);
     // TODO: Change the autogenerated stub
 }
Ejemplo n.º 5
0
 public function beforeSave($insert)
 {
     if (!$this->link) {
         $this->link = TranslitHelper::to($this->title);
     }
     if (!$this->text) {
         $this->text = '';
     }
     if (!$this->publishDate) {
         $this->publishDate = time();
     }
     return parent::beforeSave($insert);
     // TODO: Change the autogenerated stub
 }