コード例 #1
0
 /**
  * Get the hierarchy given a location sorted from root to the given
  * location.
  *
  * @param string $id The location id.
  *
  * @return LocationData[] Collection of locations
  *
  * @throws EntityNotFoundException Entity not found
  */
 public function getHierarchy($id)
 {
     $location = $this->locationRepository->findOneBy(['id' => $id]);
     if (empty($location)) {
         throw new EntityNotFoundException();
     }
     $parents = $location->getAllParents();
     $hierarchy = array_merge($parents, [$location]);
     return $this->formatOutputLocationArray($hierarchy);
 }