/**
  * Normalize LocationData object to be json encoded.
  *
  * @param LocationData $locationData Location data
  *
  * @return array Data normalized
  */
 private function normalizeLocationData(LocationData $locationData)
 {
     return ['id' => $locationData->getId(), 'name' => $locationData->getName(), 'code' => $locationData->getCode(), 'type' => $locationData->getType()];
 }
Esempio n. 2
0
 /**
  * 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);
 }