public function reverseTransform($id) { if (!$id) { return null; } $state = $this->locationService->getStateById($id); if (!$state) { $globalStateData = $this->locationService->getGlobalStateById($id); if (null === $globalStateData) { throw new \Exception('Failed to transform invalid state id: ' . $id); } $state = $this->locationService->createStateFromArray($globalStateData); } return $state; }
/** * * @param array $globaStateData * @return State */ private function getHcaState($globalStateData, Country $country) { $hcaState = $this->locationService->getStateById($globalStateData['id']); if (!$hcaState) { // create new hca state $hcaState = new State(); $hcaState->setId($globalStateData['id']); $hcaState->setName($globalStateData['name']); $hcaState->setCountry($country); } return $hcaState; }