Sulu\Bundle\ContactBundle\Contact\AbstractContactManager::updateAddress PHP Méthode

updateAddress() protected méthode

Updates the given address.
protected updateAddress ( Address $address, mixed $entry, boolean &$isMain = null ) : boolean
$address Sulu\Bundle\ContactBundle\Entity\Address The phone object to update
$entry mixed The entry with the new data
$isMain boolean returns if address should be set to main
Résultat boolean True if successful, otherwise false
    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;
    }