vendor/sulu/sulu/src/Sulu/Bundle/ContactBundle/Entity/Address.php line 25

  1. <?php
  2. /*
  3.  * This file is part of Sulu.
  4.  *
  5.  * (c) Sulu GmbH
  6.  *
  7.  * This source file is subject to the MIT license that is bundled
  8.  * with this source code in the file LICENSE.
  9.  */
  10. namespace Sulu\Bundle\ContactBundle\Entity;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use JMS\Serializer\Annotation\ExclusionPolicy;
  14. use JMS\Serializer\Annotation\Expose;
  15. use JMS\Serializer\Annotation\Groups;
  16. /**
  17.  * Address.
  18.  *
  19.  * @ExclusionPolicy("all");
  20.  */
  21. class Address
  22. {
  23.     /**
  24.      * @var string|null
  25.      *
  26.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  27.      * @Expose
  28.      */
  29.     private $street;
  30.     /**
  31.      * @var string|null
  32.      *
  33.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  34.      * @Expose
  35.      */
  36.     private $number;
  37.     /**
  38.      * @var string|null
  39.      *
  40.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  41.      * @Expose
  42.      */
  43.     private $addition;
  44.     /**
  45.      * @var string|null
  46.      *
  47.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  48.      * @Expose
  49.      */
  50.     private $zip;
  51.     /**
  52.      * @var string|null
  53.      *
  54.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  55.      * @Expose
  56.      */
  57.     private $city;
  58.     /**
  59.      * @var string|null
  60.      *
  61.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  62.      * @Expose
  63.      */
  64.     private $state;
  65.     /**
  66.      * @var int
  67.      *
  68.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  69.      * @Expose
  70.      */
  71.     private $id;
  72.     /**
  73.      * @var AddressType
  74.      *
  75.      * @Groups({"fullAccount", "fullContact"})
  76.      * @Expose
  77.      */
  78.     private $addressType;
  79.     /**
  80.      * @var string|null
  81.      *
  82.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  83.      * @Expose
  84.      */
  85.     private $countryCode;
  86.     /**
  87.      * @var bool|null
  88.      *
  89.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  90.      * @Expose
  91.      */
  92.     private $primaryAddress;
  93.     /**
  94.      * @var bool|null
  95.      *
  96.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  97.      * @Expose
  98.      */
  99.     private $deliveryAddress;
  100.     /**
  101.      * @var bool|null
  102.      *
  103.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  104.      * @Expose
  105.      */
  106.     private $billingAddress;
  107.     /**
  108.      * @var string|null
  109.      *
  110.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  111.      * @Expose
  112.      */
  113.     private $postboxNumber;
  114.     /**
  115.      * @var string|null
  116.      *
  117.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  118.      * @Expose
  119.      */
  120.     private $postboxPostcode;
  121.     /**
  122.      * @var string|null
  123.      *
  124.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  125.      * @Expose
  126.      */
  127.     private $postboxCity;
  128.     /**
  129.      * @var Collection<int, ContactAddress>
  130.      */
  131.     private $contactAddresses;
  132.     /**
  133.      * @var Collection<int, AccountAddress>
  134.      */
  135.     private $accountAddresses;
  136.     /**
  137.      * @var string|null
  138.      *
  139.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  140.      * @Expose
  141.      */
  142.     private $note;
  143.     /**
  144.      * @var string|null
  145.      *
  146.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  147.      * @Expose
  148.      */
  149.     private $title;
  150.     /**
  151.      * @var float|null
  152.      *
  153.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  154.      * @Expose
  155.      */
  156.     private $latitude;
  157.     /**
  158.      * @var float|null
  159.      *
  160.      * @Groups({"fullAccount", "partialAccount", "fullContact", "partialContact"})
  161.      * @Expose
  162.      */
  163.     private $longitude;
  164.     /**
  165.      * Constructor.
  166.      */
  167.     public function __construct()
  168.     {
  169.         $this->accountAddresses = new ArrayCollection();
  170.         $this->contactAddresses = new ArrayCollection();
  171.     }
  172.     /**
  173.      * Set street.
  174.      *
  175.      * @param string|null $street
  176.      *
  177.      * @return Address
  178.      */
  179.     public function setStreet($street)
  180.     {
  181.         $this->street $street;
  182.         return $this;
  183.     }
  184.     /**
  185.      * Get street.
  186.      *
  187.      * @return string|null
  188.      */
  189.     public function getStreet()
  190.     {
  191.         return $this->street;
  192.     }
  193.     /**
  194.      * Set number.
  195.      *
  196.      * @param string|null $number
  197.      *
  198.      * @return Address
  199.      */
  200.     public function setNumber($number)
  201.     {
  202.         $this->number $number;
  203.         return $this;
  204.     }
  205.     /**
  206.      * Get number.
  207.      *
  208.      * @return string|null
  209.      */
  210.     public function getNumber()
  211.     {
  212.         return $this->number;
  213.     }
  214.     /**
  215.      * Set addition.
  216.      *
  217.      * @param string|null $addition
  218.      *
  219.      * @return Address
  220.      */
  221.     public function setAddition($addition)
  222.     {
  223.         $this->addition $addition;
  224.         return $this;
  225.     }
  226.     /**
  227.      * Get addition.
  228.      *
  229.      * @return string|null
  230.      */
  231.     public function getAddition()
  232.     {
  233.         return $this->addition;
  234.     }
  235.     /**
  236.      * Set zip.
  237.      *
  238.      * @param string|null $zip
  239.      *
  240.      * @return Address
  241.      */
  242.     public function setZip($zip)
  243.     {
  244.         $this->zip $zip;
  245.         return $this;
  246.     }
  247.     /**
  248.      * Get zip.
  249.      *
  250.      * @return string|null
  251.      */
  252.     public function getZip()
  253.     {
  254.         return $this->zip;
  255.     }
  256.     /**
  257.      * Set city.
  258.      *
  259.      * @param string|null $city
  260.      *
  261.      * @return Address
  262.      */
  263.     public function setCity($city)
  264.     {
  265.         $this->city $city;
  266.         return $this;
  267.     }
  268.     /**
  269.      * Get city.
  270.      *
  271.      * @return string|null
  272.      */
  273.     public function getCity()
  274.     {
  275.         return $this->city;
  276.     }
  277.     /**
  278.      * Set state.
  279.      *
  280.      * @param string|null $state
  281.      *
  282.      * @return Address
  283.      */
  284.     public function setState($state)
  285.     {
  286.         $this->state $state;
  287.         return $this;
  288.     }
  289.     /**
  290.      * Get state.
  291.      *
  292.      * @return string|null
  293.      */
  294.     public function getState()
  295.     {
  296.         return $this->state;
  297.     }
  298.     /**
  299.      * Get id.
  300.      *
  301.      * @return int
  302.      */
  303.     public function getId()
  304.     {
  305.         return $this->id;
  306.     }
  307.     /**
  308.      * Set addressType.
  309.      *
  310.      * @return Address
  311.      */
  312.     public function setAddressType(AddressType $addressType)
  313.     {
  314.         $this->addressType $addressType;
  315.         return $this;
  316.     }
  317.     /**
  318.      * Get addressType.
  319.      *
  320.      * @return AddressType
  321.      */
  322.     public function getAddressType()
  323.     {
  324.         return $this->addressType;
  325.     }
  326.     /**
  327.      * Set countryCode.
  328.      *
  329.      * @return Address
  330.      */
  331.     public function setCountryCode(?string $countryCode)
  332.     {
  333.         $this->countryCode $countryCode;
  334.         return $this;
  335.     }
  336.     /**
  337.      * Get countryCode.
  338.      */
  339.     public function getCountryCode(): ?string
  340.     {
  341.         return $this->countryCode;
  342.     }
  343.     public function getCountry(): ?Country
  344.     {
  345.         if (!$this->countryCode) {
  346.             return null;
  347.         }
  348.         return new Country($this->countryCode);
  349.     }
  350.     /**
  351.      * Set primaryAddress.
  352.      *
  353.      * @param bool $primaryAddress
  354.      *
  355.      * @return Address
  356.      */
  357.     public function setPrimaryAddress($primaryAddress)
  358.     {
  359.         $this->primaryAddress $primaryAddress;
  360.         return $this;
  361.     }
  362.     /**
  363.      * Get primaryAddress.
  364.      *
  365.      * @return bool|null
  366.      */
  367.     public function getPrimaryAddress()
  368.     {
  369.         return $this->primaryAddress;
  370.     }
  371.     /**
  372.      * Set deliveryAddress.
  373.      *
  374.      * @param bool $deliveryAddress
  375.      *
  376.      * @return Address
  377.      */
  378.     public function setDeliveryAddress($deliveryAddress)
  379.     {
  380.         $this->deliveryAddress $deliveryAddress;
  381.         return $this;
  382.     }
  383.     /**
  384.      * Get deliveryAddress.
  385.      *
  386.      * @return bool|null
  387.      */
  388.     public function getDeliveryAddress()
  389.     {
  390.         return $this->deliveryAddress;
  391.     }
  392.     /**
  393.      * Set billingAddress.
  394.      *
  395.      * @param bool $billingAddress
  396.      *
  397.      * @return Address
  398.      */
  399.     public function setBillingAddress($billingAddress)
  400.     {
  401.         $this->billingAddress $billingAddress;
  402.         return $this;
  403.     }
  404.     /**
  405.      * Get billingAddress.
  406.      *
  407.      * @return bool|null
  408.      */
  409.     public function getBillingAddress()
  410.     {
  411.         return $this->billingAddress;
  412.     }
  413.     /**
  414.      * Set postboxNumber.
  415.      *
  416.      * @param string|null $postboxNumber
  417.      *
  418.      * @return Address
  419.      */
  420.     public function setPostboxNumber($postboxNumber)
  421.     {
  422.         $this->postboxNumber $postboxNumber;
  423.         return $this;
  424.     }
  425.     /**
  426.      * Get postboxNumber.
  427.      *
  428.      * @return string|null
  429.      */
  430.     public function getPostboxNumber()
  431.     {
  432.         return $this->postboxNumber;
  433.     }
  434.     /**
  435.      * Set postboxPostcode.
  436.      *
  437.      * @param string|null $postboxPostcode
  438.      *
  439.      * @return Address
  440.      */
  441.     public function setPostboxPostcode($postboxPostcode)
  442.     {
  443.         $this->postboxPostcode $postboxPostcode;
  444.         return $this;
  445.     }
  446.     /**
  447.      * Get postboxPostcode.
  448.      *
  449.      * @return string|null
  450.      */
  451.     public function getPostboxPostcode()
  452.     {
  453.         return $this->postboxPostcode;
  454.     }
  455.     /**
  456.      * Set postboxCity.
  457.      *
  458.      * @param string|null $postboxCity
  459.      *
  460.      * @return Address
  461.      */
  462.     public function setPostboxCity($postboxCity)
  463.     {
  464.         $this->postboxCity $postboxCity;
  465.         return $this;
  466.     }
  467.     /**
  468.      * Get postboxCity.
  469.      *
  470.      * @return string|null
  471.      */
  472.     public function getPostboxCity()
  473.     {
  474.         return $this->postboxCity;
  475.     }
  476.     /**
  477.      * Add contactAddresses.
  478.      *
  479.      * @return Address
  480.      */
  481.     public function addContactAddress(ContactAddress $contactAddresses)
  482.     {
  483.         $this->contactAddresses[] = $contactAddresses;
  484.         return $this;
  485.     }
  486.     /**
  487.      * Remove contactAddresses.
  488.      */
  489.     public function removeContactAddress(ContactAddress $contactAddresses)
  490.     {
  491.         $this->contactAddresses->removeElement($contactAddresses);
  492.     }
  493.     /**
  494.      * Get contactAddresses.
  495.      *
  496.      * @return Collection<int, ContactAddress>
  497.      */
  498.     public function getContactAddresses()
  499.     {
  500.         return $this->contactAddresses;
  501.     }
  502.     /**
  503.      * Add accountAddresses.
  504.      *
  505.      * @return Address
  506.      */
  507.     public function addAccountAddress(AccountAddress $accountAddresses)
  508.     {
  509.         $this->accountAddresses[] = $accountAddresses;
  510.         return $this;
  511.     }
  512.     /**
  513.      * Remove accountAddresses.
  514.      */
  515.     public function removeAccountAddress(AccountAddress $accountAddresses)
  516.     {
  517.         $this->accountAddresses->removeElement($accountAddresses);
  518.     }
  519.     /**
  520.      * Get accountAddresses.
  521.      *
  522.      * @return Collection<int, AccountAddress>
  523.      */
  524.     public function getAccountAddresses()
  525.     {
  526.         return $this->accountAddresses;
  527.     }
  528.     /**
  529.      * returns if address has at least one relation to another entity.
  530.      *
  531.      * @return bool
  532.      */
  533.     public function hasRelations()
  534.     {
  535.         if (!$this->getContactAddresses()->isEmpty()
  536.             || !$this->getAccountAddresses()->isEmpty()
  537.         ) {
  538.             return true;
  539.         }
  540.         return false;
  541.     }
  542.     /**
  543.      * Set note.
  544.      *
  545.      * @param string|null $note
  546.      *
  547.      * @return Address
  548.      */
  549.     public function setNote($note)
  550.     {
  551.         $this->note $note;
  552.         return $this;
  553.     }
  554.     /**
  555.      * Get note.
  556.      *
  557.      * @return string|null
  558.      */
  559.     public function getNote()
  560.     {
  561.         return $this->note;
  562.     }
  563.     /**
  564.      * Set title.
  565.      *
  566.      * @param string|null $title
  567.      *
  568.      * @return Address
  569.      */
  570.     public function setTitle($title)
  571.     {
  572.         $this->title $title;
  573.         return $this;
  574.     }
  575.     /**
  576.      * Get title.
  577.      *
  578.      * @return string|null
  579.      */
  580.     public function getTitle()
  581.     {
  582.         return $this->title;
  583.     }
  584.     /**
  585.      * Returns latitude.
  586.      *
  587.      * @return float|null
  588.      */
  589.     public function getLatitude()
  590.     {
  591.         return $this->latitude;
  592.     }
  593.     /**
  594.      * Set latitude.
  595.      *
  596.      * @param float|null $latitude
  597.      *
  598.      * @return Address
  599.      */
  600.     public function setLatitude($latitude)
  601.     {
  602.         $this->latitude $latitude;
  603.         return $this;
  604.     }
  605.     /**
  606.      * Returns longitude.
  607.      *
  608.      * @return float|null
  609.      */
  610.     public function getLongitude()
  611.     {
  612.         return $this->longitude;
  613.     }
  614.     /**
  615.      * Set longitude.
  616.      *
  617.      * @param float|null $longitude
  618.      *
  619.      * @return Address
  620.      */
  621.     public function setLongitude($longitude)
  622.     {
  623.         $this->longitude $longitude;
  624.         return $this;
  625.     }
  626. }