/**
  * Prints out the location name, and recursively calls itself on each its children
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  * @param int $depth The current depth
  *
  * @param OutputInterface $output
  */
 private function browseLocation(Location $location, OutputInterface $output, $depth = 0)
 {
     // indent according to depth and write out the name of the content
     $output->write(str_pad(' ', $depth));
     $output->writeln($location->contentInfo->name);
     // we request the location's children using the location service, and call browseLocation on each
     $childLocations = $this->locationService->loadLocationChildren($location);
     foreach ($childLocations->locations as $childLocation) {
         $this->browseLocation($childLocation, $output, $depth + 1);
     }
 }
Пример #2
0
 /**
  * Loads child locations of a location
  *
  * @param string $locationPath
  *
  * @return \eZ\Publish\Core\REST\Server\Values\LocationList
  */
 public function loadLocationChildren($locationPath)
 {
     $offset = $this->request->query->has('offset') ? (int) $this->request->query->get('offset') : 0;
     $limit = $this->request->query->has('limit') ? (int) $this->request->query->get('limit') : -1;
     $restLocations = array();
     $locationId = $this->extractLocationIdFromPath($locationPath);
     foreach ($this->locationService->loadLocationChildren($this->locationService->loadLocation($locationId), $offset >= 0 ? $offset : 0, $limit >= 0 ? $limit : -1)->locations as $location) {
         $restLocations[] = new Values\RestLocation($location, $this->locationService->getLocationChildCount($location));
     }
     return new Values\CachedValue(new Values\LocationList($restLocations, $this->request->getPathInfo()), array('locationId' => $locationId));
 }
Пример #3
0
 /**
  * Loads children which are readable by the current user of a location object sorted by sortField and sortOrder
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  * @param int $offset the start offset for paging
  * @param int $limit the number of locations returned
  *
  * @return \eZ\Publish\API\Repository\Values\Content\LocationList
  */
 public function loadLocationChildren(Location $location, $offset = 0, $limit = 10)
 {
     return $this->service->loadLocationChildren($location, $offset, $limit);
 }