예제 #1
0
 /**
  * Formats an address on an array.
  *
  * @param AddressInterface $address The address to format
  *
  * @return array
  */
 public function toArray(AddressInterface $address)
 {
     $cityLocationId = $address->getCity();
     $cityHierarchy = $this->locationProvider->getHierarchy($cityLocationId);
     $cityHierarchyAsc = array_reverse($cityHierarchy);
     $addressArray = ['id' => $address->getId(), 'name' => $address->getName(), 'recipientName' => $address->getRecipientName(), 'recipientSurname' => $address->getRecipientSurname(), 'address' => $address->getAddress(), 'addressMore' => $address->getAddressMore(), 'postalCode' => $address->getPostalcode(), 'phone' => $address->getPhone(), 'mobile' => $address->getMobile(), 'comment' => $address->getComments()];
     foreach ($cityHierarchyAsc as $cityLocationNode) {
         /**
          * @var LocationData $cityLocationNode
          */
         $addressArray['city'][$cityLocationNode->getType()] = $cityLocationNode->getName();
     }
     $addressArray['fullAddress'] = $this->buildFullAddressString($address, $addressArray['city']);
     return $addressArray;
 }
예제 #2
0
 /**
  * Get the hierarchy given a location sorted from root to the given
  * location.
  *
  * @return Response Data serialized in json
  */
 public function getHierarchyAction()
 {
     $id = $this->request->query->get('id');
     return $this->createResponseObject(function () use($id) {
         return $this->normalizeLocationDataArray($this->locationProvider->getHierarchy($id));
     });
 }
예제 #3
0
 /**
  * Gets the location hierarchy.
  *
  * @param string $locationId The location identifier
  *
  * @return \Elcodi\Component\Geo\ValueObject\LocationData[]
  */
 protected function getHierarchy($locationId)
 {
     try {
         $hierarchy = $this->locationProvider->getHierarchy($locationId);
     } catch (EntityNotFoundException $e) {
         $hierarchy = [];
     }
     return $hierarchy;
 }
예제 #4
0
 /**
  * Gets the address hierarchy.
  *
  * @param AddressInterface $address
  *
  * @return LocationData[] Addres hierarchy
  */
 private function getAddressHierarchy(AddressInterface $address)
 {
     return $this->locationProvider->getHierarchy($address->getCity());
 }
 /**
  * Public function test get hierarchy not found.
  */
 public function testGetHierarchyNotFound()
 {
     $this->setExpectedException('Doctrine\\ORM\\EntityNotFoundException');
     $this->locationProviderAdapter->getHierarchy('UNEXISTENT');
 }