예제 #1
0
파일: NavItem.php 프로젝트: aekkapun/luya
 public function logEvent($e)
 {
     switch ($e->name) {
         case 'afterInsert':
             Log::add(1, "nav_item.insert '" . $this->title . "', cms_nav_item.id '" . $this->id . "'", $this->toArray());
             break;
         case 'afterUpdate':
             Log::add(2, "nav_item.update '" . $this->title . "', cms_nav_item.id '" . $this->id . "'", $this->toArray());
             break;
         case 'afterDelete':
             Log::add(3, "nav_item.delete '" . $this->title . "', cms_nav_item.id '" . $this->id . "'", $this->toArray());
             break;
     }
 }
예제 #2
0
 public function eventAfterInsert()
 {
     $this->reindex($this->nav_item_page_id, $this->placeholder_var, $this->prev_id);
     Log::add(1, "block.insert '" . $this->block->class . "', cms_nav_item_page_block_item.id '" . $this->id . "'");
 }
예제 #3
0
파일: Nav.php 프로젝트: aekkapun/luya
 public function reindex($e)
 {
     $i = 1;
     foreach (self::find()->where(['nav_container_id' => $this->nav_container_id, 'parent_nav_id' => $this->parent_nav_id])->orderBy('sort_index ASC')->asArray()->all() as $model) {
         Yii::$app->db->createCommand()->update(self::tableName(), ['sort_index' => $i], 'id=:id', ['id' => $model['id']])->execute();
         ++$i;
     }
     switch ($e->name) {
         case 'afterInsert':
             Log::add(1, "nav.insert, cms_nav.id '" . $this->id . "'", $this->toArray());
             break;
         case 'afterUpdate':
             Log::add(2, "nav.update, cms_nav.id '" . $this->id . "'", $this->toArray());
             break;
         case 'afterDelete':
             Log::add(3, "nav.delete, cms_nav.id '" . $this->id . "'", $this->toArray());
             break;
     }
 }