Beispiel #1
0
 /**
  * @PreSave
  */
 public function preSave(EntityEvent $event)
 {
     if (!$this->id) {
         $this->setPriority($event->getConnection()->fetchColumn('SELECT MAX(priority) + 1 FROM @system_role'));
     }
 }
Beispiel #2
0
 /**
  * Delete all orphaned user role relations.
  *
  * @PostDelete
  */
 public function postDelete(EntityEvent $event)
 {
     $event->getConnection()->delete('@system_user_role', ['user_id' => $this->getId()]);
 }
Beispiel #3
0
 /**
  * @PreSave
  */
 public function preSave(EntityEvent $event)
 {
     if (!$this->id) {
         $this->setPriority($event->getConnection()->fetchColumn('SELECT MAX(priority) + 1 FROM @system_menu_item WHERE menu_id=? AND DEPTH=0', [$this->getMenuId()]) ?: 0);
     }
 }
Beispiel #4
0
 /**
  * @PreDelete
  */
 public function preDelete(EntityEvent $event)
 {
     $event->getConnection()->delete('@blog_comment', ['post_id' => $this->getId()]);
 }