Sulu\Bundle\ContactBundle\Entity\AccountAddress::getAddress PHP Method

getAddress() public method

Get address.
public getAddress ( ) : Address
return Address
    public function getAddress()
    {
        return $this->address;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * removes the address relation from a contact and also deletes the address if it has no more relations.
  *
  * @param AccountInterface     $account
  * @param AccountAddressEntity $accountAddress
  *
  * @return mixed|void
  *
  * @throws \Exception
  */
 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);
 }