コード例 #1
0
 /**
  * Adding or deleting children if needed
  */
 protected function manageRelations()
 {
     foreach ($this->_children as $p => $kids) {
         $parent = $this->_items[$p];
         foreach ($kids as $k) {
             $kid = $this->_items[$k];
             if (!$this->_auth->hasChild($parent, $kid)) {
                 Console::stdout($kid->name . ' added as a child of ' . $parent->name . "\n");
                 $this->_auth->addChild($parent, $kid);
             }
         }
         foreach ($this->_auth->getChildren($p) as $current_kid) {
             if (!in_array($current_kid->name, $kids)) {
                 Console::stdout(Console::ansiFormat('Relation between  ' . $current_kid->name . ' and ' . $parent->name . " was removed!\n", [Console::FG_RED]));
                 $this->_auth->removeChild($parent, $current_kid);
             }
         }
     }
 }