protected function updateAddress(Address $address, $entry, &$isMain = null)
{
$success = true;
$addressType = $this->em->getRepository(self::$addressTypeEntityName)->find($entry['addressType']['id']);
$country = $this->em->getRepository(self::$countryEntityName)->find($entry['country']['id']);
if (!$addressType) {
throw new EntityNotFoundException(self::$addressTypeEntityName, $entry['addressType']['id']);
} else {
if (!$country) {
throw new EntityNotFoundException(self::$countryEntityName, $entry['country']['id']);
} else {
$address->setStreet($entry['street']);
$address->setNumber($entry['number']);
$address->setZip($entry['zip']);
$address->setCity($entry['city']);
$address->setState($entry['state']);
$address->setCountry($country);
$address->setAddressType($addressType);
if (isset($entry['note'])) {
$address->setNote($entry['note']);
}
if (isset($entry['title'])) {
$address->setTitle($entry['title']);
}
if (isset($entry['primaryAddress'])) {
$isMain = $this->getBooleanValue($entry['primaryAddress']);
} else {
$isMain = false;
}
if (isset($entry['billingAddress'])) {
$address->setBillingAddress($this->getBooleanValue($entry['billingAddress']));
}
if (isset($entry['deliveryAddress'])) {
$address->setDeliveryAddress($this->getBooleanValue($entry['deliveryAddress']));
}
if (isset($entry['postboxCity'])) {
$address->setPostboxCity($entry['postboxCity']);
}
if (isset($entry['postboxNumber'])) {
$address->setPostboxNumber($entry['postboxNumber']);
}
if (isset($entry['postboxPostcode'])) {
$address->setPostboxPostcode($entry['postboxPostcode']);
}
if (isset($entry['addition'])) {
$address->setAddition($entry['addition']);
}
}
}
return $success;
}