Elcodi\Admin\GeoBundle\Form\LocationSelectorBuilder::buildChildrenSelects PHP Method

buildChildrenSelects() private method

Builds the children (Not root) selectors given a hierarchy, we also use the root location to know which one is selected.
private buildChildrenSelects ( Elcodi\Component\Geo\ValueObject\LocationData $selectedRootLocation, array $hierarchy )
$selectedRootLocation Elcodi\Component\Geo\ValueObject\LocationData
$hierarchy array
    private 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);
    }