Beispiel #1
0
 /**
  * Saves an address making a copy in case it was already persisted. Then
  * returns the saved address.
  *
  * @param AddressInterface $address The address to save
  *
  * @return AddressInterface saved address.
  */
 public function saveAddress(AddressInterface $address)
 {
     if ($address->getId()) {
         $addressToSave = clone $address;
         $addressToSave->setId(null);
         $this->addressObjectManager->refresh($address);
         $this->addressObjectManager->persist($addressToSave);
         $this->addressObjectManager->flush($addressToSave);
         $this->addressEventDispatcher->dispatchAddressOnCloneEvent($address, $addressToSave);
         return $addressToSave;
     }
     $this->addressObjectManager->flush($address);
     return $address;
 }
 /**
  * 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;
 }
Beispiel #3
0
 /**
  * Get id
  *
  * @return string Id
  */
 public function getId()
 {
     return $this->address->getId();
 }
Beispiel #4
0
 /**
  * Finds all the carts that had an address for billing or delivery
  *
  * @param AddressInterface $address The address to search
  *
  * @return CartInterface[]
  */
 public function findAllCartsWithAddress(AddressInterface $address)
 {
     $queryBuilder = $this->createQueryBuilder('c');
     $result = $queryBuilder->innerJoin('c.billingAddress', 'b')->innerJoin('c.deliveryAddress', 'd')->where($queryBuilder->expr()->orX($queryBuilder->expr()->eq('b.id', ':customerId'), $queryBuilder->expr()->eq('c.id', ':addressId')))->setParameter('customerId', $address->getId())->setParameter('addressId', $address->getId())->getQuery()->getResult();
     return $result;
 }