/**
  * Get the children given a location id.
  *
  * @return Response Data serialized in json
  */
 public function getChildrenAction()
 {
     $id = $this->request->query->get('id');
     return $this->createResponseObject(function () use($id) {
         return $this->normalizeLocationDataArray($this->locationProvider->getChildren($id));
     });
 }
 /**
  * Builds the children (Not root) selectors given a hierarchy, we also use
  * the root location to know which one is selected.
  *
  * @param LocationData $selectedRootLocation
  * @param              $hierarchy
  */
 protected function buildChildrenSelects(LocationData $selectedRootLocation, array $hierarchy)
 {
     $childrenLocations = $this->locationProvider->getChildren($selectedRootLocation->getId());
     do {
         $selectedRootLocation = array_shift($hierarchy);
         $locationExample = reset($childrenLocations);
         $options = $this->generateOptions($childrenLocations);
         if ($selectedRootLocation) {
             $selected = $selectedRootLocation->getId();
             $childrenLocations = $this->maxLocationType !== $locationExample->getType() ? $childrenLocations = $this->locationProvider->getChildren($selectedRootLocation->getId()) : null;
         } else {
             $selected = null;
             $childrenLocations = null;
         }
         $this->selects[] = $this->formatSelector($locationExample->getType(), $options, $selected);
     } while ($childrenLocations);
 }
 /**
  * Test get children with a location without children
  */
 public function testGetChildrenNotFound()
 {
     $locations = $this->locationProviderAdapter->getChildren('ES_CA_VO_SantCeloni_08470');
     $this->assertCount(0, $locations, 'We don\'t expect any location to be returned');
 }