removeChildren() public method

Note, the children items are not deleted. Only the parent-child relationships are removed.
public removeChildren ( Item $parent ) : boolean
$parent Item
return boolean whether the removal is successful
Esempio n. 1
0
 /**
  * @param ManagerInterface $auth
  * @param string $name
  * @param array $children
  */
 private function removePermission($auth, $name, $children = array())
 {
     $permission = $auth->getPermission($name);
     $auth->removeChildren($permission);
     if ($children) {
         foreach ($children as $childName => $childOptions) {
             $this->removePermission($auth, $childName, isset($childOptions['children']) ? $childOptions['children'] : array());
         }
     }
     $auth->remove($permission);
 }
Esempio n. 2
0
 /**
  * @param bool $validate
  * @return bool
  */
 public function save($validate = true)
 {
     if ($validate && !$this->validate()) {
         return false;
     }
     if ($this->isNewRecord) {
         $this->role = $this->auth->createRole($this->name);
         $this->role->description = $this->description;
         if (!$this->auth->add($this->role)) {
             return false;
         }
     } else {
         $this->role->name = $this->name;
         $this->role->description = $this->description;
         if (!$this->auth->update($this->oldName, $this->role)) {
             return false;
         }
         $this->auth->removeChildren($this->role);
     }
     foreach ($this->actions as $action) {
         $this->auth->addChild($this->role, $this->auth->getPermission($action));
     }
     return true;
 }
Esempio n. 3
0
File: Role.php Progetto: apurey/cmf
 /**
  * @param string $name
  * @param array $permissions
  * @param array $roles
  * @return bool
  */
 public function updateRole($name, array $permissions, array $roles)
 {
     if ($this->validate()) {
         $object = $this->authManager->getRole($name);
         $object->description = $this->description;
         if ($this->authManager->update($name, $object)) {
             $this->authManager->removeChildren($object);
             foreach ($permissions as $permission) {
                 $this->authManager->addChild($object, $this->authManager->getPermission($permission));
             }
             foreach ($roles as $role) {
                 $this->authManager->addChild($object, $this->authManager->getRole($role));
             }
             return true;
         }
     }
     return false;
 }