저자: XE Team (developers) (developers@xpressengine.com)
예제 #1
0
 /**
  * Add parent to ancestor
  *
  * @param Permission $parent parent instance
  * @return void
  */
 public function addParent(Permission $parent)
 {
     if ($this->isParent($parent) === true) {
         $this->parent = $parent;
     } elseif ($this->parent !== null) {
         $this->parent->addParent($parent);
     }
 }
예제 #2
0
 /**
  * Move entity hierarchy to new parent or root
  *
  * @param Permission  $permission permission instance
  * @param string|null $to         to prefix
  * @return void
  * @throws InvalidArgumentException
  * @throws NoParentException
  */
 public function move(Permission $permission, $to = null)
 {
     $toParent = $to !== null ? $this->repo->findByName($permission->siteKey, $to) : null;
     if ($to !== null && $toParent === null || $toParent !== null && $permission->type != $toParent->type) {
         throw new InvalidArgumentException(['arg' => $to]);
     }
     $parent = $permission->getParent();
     if ($parent === null) {
         if ($permission->getDepth() !== 1) {
             throw new NoParentException();
         }
         $this->repo->affiliate($permission, $to);
     } else {
         $this->repo->foster($permission, $to);
     }
 }
예제 #3
0
 /**
  * Update register information
  *
  * @param Permission $item permission instance
  *
  * @return Permission
  */
 public function update(Permission $item)
 {
     $diff = $item->getDirty();
     $dates = [];
     if (count($diff) > 0) {
         $dates = ['updatedAt' => $this->getNow()];
         $this->conn->table($this->table)->where('id', $item->id)->update(array_merge($diff, $dates));
     }
     return $this->createItem(array_merge($item->getOriginal(), $diff, $dates));
 }