Sets delivery address for an item.

@param array|int $addressData
@param ApiItemInterface $item
@param ContactInterface $contact
@param AccountInterface $account

@throws ItemDependencyNotFoundException
@throws ItemException
511104
protected function setItemDeliveryAddress(
        $addressData,
        ApiItemInterface $item,
        ContactInterface $contact = null,
        AccountInterface $account = null
    ) {
        if ($item->getDeliveryAddress() === null) {
            // Create new delivery address.
            $deliveryAddress = new $this->orderAddressEntity();
            // Persist entities.
            $this->em->persist($deliveryAddress);
            // Assign to order.
            $item->setDeliveryAddress($deliveryAddress);
        }

        if (is_array($addressData)) {
            // Set order-address.
            $this->orderAddressManager->setOrderAddress(
                $item->getDeliveryAddress(),
                $addressData,
                $contact,
                $account
            );
        } elseif (is_int($addressData)) {
            $contactAddressId = $addressData;
            // Create order-address and assign contact-address data.
            $deliveryAddress = $item->getEntity()->getDeliveryAddress();

            $orderAddress = $this->orderAddressManager->getAndSetOrderAddressByContactAddressId(
                $contactAddressId,
                $contact,
                $account,
                $deliveryAddress
            );

            // Set delivery address.
            $item->setDeliveryAddress($orderAddress);

            // If new delivery address persist.
            if (!$deliveryAddress) {
                $this->em->persist($orderAddress);
            }
        }
    }
384201
public function setDefaultShippingAddress(string $type, string $addressId, SalesChannelContext $context): RedirectResponse
    {
        $this->denyAccessUnlessLoggedIn();

        if (!Uuid::isValid($addressId)) {
            throw new InvalidUuidException($addressId);
        }

        $success = true;
        try {
            if ($type === 'shipping') {
                $this->accountService->setDefaultShippingAddress($addressId, $context);
            } elseif ($type === 'billing') {
                $this->accountService->setDefaultBillingAddress($addressId, $context);
            } else {
                $success = false;
            }
        } catch (AddressNotFoundException $exception) {
            $success = false;
        }

        $this->salesChannelContextService->refresh(
            $context->getSalesChannel()->getId(),
            $context->getToken(),
            $context->getContext()->getLanguageId()
        );

        return new RedirectResponse($this->generateUrl('frontend.account.address.page', [
            'changedDefaultAddress' => $success,
        ]));
    }
1000317
public function setEmailAddress($emailAddress)
    {
        if ($emailAddress != null)
        {
            if (filter_var(trim($emailAddress), FILTER_VALIDATE_EMAIL) === false)
            {
                throw new InvalidArgumentException($emailAddress . " is not a valid email address.");
            }
        }

        $this->emailAddress = $emailAddress;
    }
87480
private function updateStepAddressDataForAddressId($newShippingAddressId, $newBillingAddressId)
    {
        $newBillingAddress = TdbDataExtranetUserAddress::GetNewInstance();
        if (true === $newBillingAddress->Load($newBillingAddressId)) {
            $this->SetBillingAddressData($newBillingAddress->sqlData);
        }
        if ($newShippingAddressId === $newBillingAddressId) {
            $this->SetShippingAddressData($newBillingAddress->sqlData);
        } else {
            $newShippingAddress = TdbDataExtranetUserAddress::GetNewInstance();
            if (true === $newShippingAddress->Load($newShippingAddressId)) {
                $this->SetShippingAddressData($newShippingAddress->sqlData);
            }
        }
    }
645415
public function setItemOrderShippingName(&$item, $shipping_model)
    {
        if (isset($item['shipping'])) {
            $data = $shipping_model->get($item['shipping']);
            $item['shipping_name'] = empty($data['title']) ? 'Unknown' : $data['title'];
        }
    }
713384
public function addItemToReplacementData( $itemId )
    {
        if ( !isset( $this->replacementData[$itemId] ) )
        {
            $this->replacementData[$itemId] = 0;
        }
        ++$this->replacementData[$itemId];
    }
1318937
public function setShipping($address, $type = null)
    {
        $param = $address;
        if ($param instanceof PagSeguroShipping) {
            $this->shipping = $param;
        } else {
            $shipping = new PagSeguroShipping();
            if (is_array($param)) {
                $shipping->setAddress(new PagSeguroAddress($param));
            } else {
                if ($param instanceof PagSeguroAddress) {
                    $shipping->setAddress($param);
                }
            }
            if ($type) {
                if ($type instanceof PagSeguroShippingType) {
                    $shipping->setType($type);
                } else {
                    $shipping->setType(new PagSeguroShippingType($type));
                }
            }
            $this->shipping = $shipping;
        }
    }
794243
public function storeItemVariables($deliveryResultIdentifier, $test, $item, array $itemVariables, $callIdItem)
    {
        $variables = [];

        foreach ($itemVariables as $itemVariable) {
            $variables[] = $this->handleFiles($deliveryResultIdentifier, $itemVariable);
        }

        $this->getDbStorage()->storeItemVariables(
            $deliveryResultIdentifier,
            $test,
            $item,
            $variables,
            $callIdItem
        );
    }
576958
public function setItemMark(\AgentSIB\Diadoc\Api\Proto\Invoicing\ItemMark $value = null)
    {
        $this->ItemMark = $value;
    }
263220
public void setReplyTo(String address, String personal) throws AddressException {
		replyTo = toInternetAddress(address, personal);
	}
1156599
public function set(CacheableInterface $item)
    {
        $this->connection->set($item->getHashKey(), $item->getDataForCache(), $item->getTtl());
    }
1085615
public function mergeContactIntoAddressData(array &$addressData, ContactInterface $contact)
    {
        $addressData['firstName'] = $contact->getFirstName();
        $addressData['lastName'] = $contact->getLastName();
        $addressData['fullName'] = $contact->getFullName();
        $addressData['salutation'] = $contact->getSalutation();
        $addressData['formOfAddress'] = $contact->getFormOfAddress();
        if ($contact->getTitle() !== null) {
            $addressData['title'] = $contact->getTitle()->getTitle();
        }
    }
375605
public function setItemOrderAddress(&$order, $address_model)
    {
        $order['address'] = array();

        foreach (array('shipping', 'payment') as $type) {
            $address = $address_model->get($order["{$type}_address"]);
            if (!empty($address)) {
                $order['address'][$type] = $address;
                $order['address_translated'][$type] = $address_model->getTranslated($order['address'][$type], true);
            }
        }
    }
61649
public function removeAddressRelation($account, $accountAddress)
    {
        if (!$account || !$accountAddress) {
            throw new \Exception('Account and AccountAddress cannot be null');
        }

        // Reload address to get all data (including relational data).
        /** @var AddressEntity $address */
        $address = $accountAddress->getAddress();
        $address = $this->em->getRepository('SuluContactBundle:Address')
            ->findById($address->getId());

        $isMain = $accountAddress->getMain();

        // Remove relation.
        $address->removeAccountAddress($accountAddress);
        $account->removeAccountAddress($accountAddress);

        // If was main, set a new one.
        if ($isMain) {
            $this->setMainForCollection($account->getAccountContacts());
        }

        // Delete address if it has no more relations.
        if (!$address->hasRelations()) {
            $this->em->remove($address);
        }

        $this->em->remove($accountAddress);
    }
331263
private function createShippingItemEntity($data)
    {
        // check if necessary item data is set
        if (array_key_exists('item', $data) && array_key_exists('id', $data['item'])) {
            $itemId = $data['item']['id'];
            $item = $this->itemManager->findEntityById($itemId);
            if (!$item) {
                throw new ShippingDependencyNotFoundException('SuluSalesCoreBundle:Items', $itemId);
            }

            $shippingItem = new ShippingItemEntity();
            $shippingItem->setItem($item);
            $this->em->persist($shippingItem);
        } else {
            throw new MissingShippingAttributeException('ShippingItems.item.id');
        }

        return $shippingItem;
    }
178991
private function setAddressDataForOrder(&$orderAddress, $addressData)
    {
        $orderAddress->setStreet($this->getProperty($addressData, 'street', ''));
        $orderAddress->setNumber($this->getProperty($addressData, 'number', ''));
        $orderAddress->setAddition($this->getProperty($addressData, 'addition', ''));
        $orderAddress->setCity($this->getProperty($addressData, 'city', ''));
        $orderAddress->setZip($this->getProperty($addressData, 'zip', ''));
        $orderAddress->setState($this->getProperty($addressData, 'state', ''));

        $countryName = $this->getProperty($addressData, 'country', '');
        // Get country name if country is an array.
        if (is_array($countryName)) {
            $countryName = '';
            if (isset($countryName['name'])) {
                $countryName = $countryName['name'];
            }
        }
        $orderAddress->setCountry($countryName);
        $orderAddress->setEmail($this->getProperty($addressData, 'email', ''));
        $orderAddress->setPhone($this->getProperty($addressData, 'phone', ''));
        $orderAddress->setNote($this->getProperty($addressData, 'note', ''));

        $orderAddress->setPostboxCity($this->getProperty($addressData, 'postboxCity', ''));
        $orderAddress->setPostboxPostcode($this->getProperty($addressData, 'postboxPostcode', ''));
        $orderAddress->setPostboxNumber($this->getProperty($addressData, 'postboxNumber', ''));

        $address = null;
        if ($this->getProperty($addressData, 'address')) {
            $address = $this->getProperty($addressData, 'address');
        } elseif ($this->getProperty($addressData, 'contactAddress')) {
            $address = $this->getProperty($addressData, 'contactAddress');
        }
        if ($address) {
            $this->getAndSetOrderAddressByContactAddressId($address, null, null, $orderAddress);
        }
    }
308897
@Override
  public final void setItem(final ServiceToSale pService) {
    this.item = pService;
    if (this.itsId == null) {
      this.itsId = new ServicePlaceId();
    }
    this.itsId.setItem(this.item);
  }