コード例 #1
0
 /**
  * @param IItem $item Start item
  */
 public function __construct(IItem $item)
 {
     $current = $item->getParent();
     if ($current) {
         // If root isn't the only item in structure
         // Until we get to the root item
         while ($current->getParent()) {
             $this->itemPath[] = $current;
             $current = $current->getParent();
         }
     }
     $this->itemPath = array_reverse($this->itemPath);
 }
コード例 #2
0
ファイル: Firi.php プロジェクト: appsco/component-firi
 /**
  * @param IItem $item
  * @return null|IItem
  * @throws Component\Exception\Exception
  */
 public function remove(IItem $item)
 {
     if (null === $item->getParent()) {
         throw new Exception('Root item can\'t be removed');
     }
     $parent = $item->getParent();
     $parent->removeChild($item);
     return $parent;
 }
コード例 #3
0
 /**
  * Checks if current position is valid
  *
  * @return bool
  */
 public function valid()
 {
     return $this->current->getParent() !== null;
 }