listChildren() публичный Метод

Lists the child resources of the resources.
public listChildren ( ) : Puli\Repository\Api\ResourceCollection
Результат Puli\Repository\Api\ResourceCollection The child resources indexed by their names.
Пример #1
0
 /**
  * Recursively prints the tree for the given resource.
  *
  * @param IO           $io       The I/O.
  * @param PuliResource $resource The printed resource.
  * @param int          $total    Collects the total number of printed resources.
  * @param string       $prefix   The prefix for all printed resources.
  */
 private function printTree(IO $io, PuliResource $resource, &$total, $prefix = '')
 {
     // The root node has an empty name
     $children = $resource->listChildren();
     $lastIndex = count($children) - 1;
     $index = 0;
     foreach ($children as $child) {
         $isLastChild = $index === $lastIndex;
         $childPrefix = $isLastChild ? self::LAST_CHILD_PREFIX : self::CHILD_PREFIX;
         $nestingPrefix = $isLastChild ? self::NESTING_CLOSED_PREFIX : self::NESTING_OPEN_PREFIX;
         $name = $child->getName() ?: '/';
         if ($child->hasChildren()) {
             $name = '<c1>' . $name . '</c1>';
         }
         $io->writeLine($prefix . $childPrefix . $name);
         $this->printTree($io, $child, $total, $prefix . $nestingPrefix);
         ++$index;
         ++$total;
     }
 }
Пример #2
0
 private function addResource($path, PuliResource $resource)
 {
     $basePath = '/' === $path ? $path : $path . '/';
     // Read children before attaching the resource to this repository
     $children = $resource->listChildren();
     $resource = clone $resource;
     $resource->attachTo($this, $path);
     // Add the resource before adding its children, so that the array
     // stays sorted
     $this->resources[$path] = $resource;
     foreach ($children as $name => $child) {
         $this->addResource($basePath . $name, $child);
     }
     $this->storeVersion($resource);
 }