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.      * @param string $countryCode
  330.      *
  331.      * @return Address
  332.      */
  333.     public function setCountryCode(?string $countryCode)
  334.     {
  335.         $this->countryCode $countryCode;
  336.         return $this;
  337.     }
  338.     /**
  339.      * Get countryCode.
  340.      */
  341.     public function getCountryCode(): ?string
  342.     {
  343.         return $this->countryCode;
  344.     }
  345.     public function getCountry(): ?Country
  346.     {
  347.         if (!$this->countryCode) {
  348.             return null;
  349.         }
  350.         return new Country($this->countryCode);
  351.     }
  352.     /**
  353.      * Set primaryAddress.
  354.      *
  355.      * @param bool $primaryAddress
  356.      *
  357.      * @return Address
  358.      */
  359.     public function setPrimaryAddress($primaryAddress)
  360.     {
  361.         $this->primaryAddress $primaryAddress;
  362.         return $this;
  363.     }
  364.     /**
  365.      * Get primaryAddress.
  366.      *
  367.      * @return bool|null
  368.      */
  369.     public function getPrimaryAddress()
  370.     {
  371.         return $this->primaryAddress;
  372.     }
  373.     /**
  374.      * Set deliveryAddress.
  375.      *
  376.      * @param bool $deliveryAddress
  377.      *
  378.      * @return Address
  379.      */
  380.     public function setDeliveryAddress($deliveryAddress)
  381.     {
  382.         $this->deliveryAddress $deliveryAddress;
  383.         return $this;
  384.     }
  385.     /**
  386.      * Get deliveryAddress.
  387.      *
  388.      * @return bool|null
  389.      */
  390.     public function getDeliveryAddress()
  391.     {
  392.         return $this->deliveryAddress;
  393.     }
  394.     /**
  395.      * Set billingAddress.
  396.      *
  397.      * @param bool $billingAddress
  398.      *
  399.      * @return Address
  400.      */
  401.     public function setBillingAddress($billingAddress)
  402.     {
  403.         $this->billingAddress $billingAddress;
  404.         return $this;
  405.     }
  406.     /**
  407.      * Get billingAddress.
  408.      *
  409.      * @return bool|null
  410.      */
  411.     public function getBillingAddress()
  412.     {
  413.         return $this->billingAddress;
  414.     }
  415.     /**
  416.      * Set postboxNumber.
  417.      *
  418.      * @param string|null $postboxNumber
  419.      *
  420.      * @return Address
  421.      */
  422.     public function setPostboxNumber($postboxNumber)
  423.     {
  424.         $this->postboxNumber $postboxNumber;
  425.         return $this;
  426.     }
  427.     /**
  428.      * Get postboxNumber.
  429.      *
  430.      * @return string|null
  431.      */
  432.     public function getPostboxNumber()
  433.     {
  434.         return $this->postboxNumber;
  435.     }
  436.     /**
  437.      * Set postboxPostcode.
  438.      *
  439.      * @param string|null $postboxPostcode
  440.      *
  441.      * @return Address
  442.      */
  443.     public function setPostboxPostcode($postboxPostcode)
  444.     {
  445.         $this->postboxPostcode $postboxPostcode;
  446.         return $this;
  447.     }
  448.     /**
  449.      * Get postboxPostcode.
  450.      *
  451.      * @return string|null
  452.      */
  453.     public function getPostboxPostcode()
  454.     {
  455.         return $this->postboxPostcode;
  456.     }
  457.     /**
  458.      * Set postboxCity.
  459.      *
  460.      * @param string|null $postboxCity
  461.      *
  462.      * @return Address
  463.      */
  464.     public function setPostboxCity($postboxCity)
  465.     {
  466.         $this->postboxCity $postboxCity;
  467.         return $this;
  468.     }
  469.     /**
  470.      * Get postboxCity.
  471.      *
  472.      * @return string|null
  473.      */
  474.     public function getPostboxCity()
  475.     {
  476.         return $this->postboxCity;
  477.     }
  478.     /**
  479.      * Add contactAddresses.
  480.      *
  481.      * @return Address
  482.      */
  483.     public function addContactAddress(ContactAddress $contactAddresses)
  484.     {
  485.         $this->contactAddresses[] = $contactAddresses;
  486.         return $this;
  487.     }
  488.     /**
  489.      * Remove contactAddresses.
  490.      */
  491.     public function removeContactAddress(ContactAddress $contactAddresses)
  492.     {
  493.         $this->contactAddresses->removeElement($contactAddresses);
  494.     }
  495.     /**
  496.      * Get contactAddresses.
  497.      *
  498.      * @return Collection<int, ContactAddress>
  499.      */
  500.     public function getContactAddresses()
  501.     {
  502.         return $this->contactAddresses;
  503.     }
  504.     /**
  505.      * Add accountAddresses.
  506.      *
  507.      * @return Address
  508.      */
  509.     public function addAccountAddress(AccountAddress $accountAddresses)
  510.     {
  511.         $this->accountAddresses[] = $accountAddresses;
  512.         return $this;
  513.     }
  514.     /**
  515.      * Remove accountAddresses.
  516.      */
  517.     public function removeAccountAddress(AccountAddress $accountAddresses)
  518.     {
  519.         $this->accountAddresses->removeElement($accountAddresses);
  520.     }
  521.     /**
  522.      * Get accountAddresses.
  523.      *
  524.      * @return Collection<int, AccountAddress>
  525.      */
  526.     public function getAccountAddresses()
  527.     {
  528.         return $this->accountAddresses;
  529.     }
  530.     /**
  531.      * returns if address has at least one relation to another entity.
  532.      *
  533.      * @return bool
  534.      */
  535.     public function hasRelations()
  536.     {
  537.         if (!$this->getContactAddresses()->isEmpty() ||
  538.             !$this->getAccountAddresses()->isEmpty()
  539.         ) {
  540.             return true;
  541.         }
  542.         return false;
  543.     }
  544.     /**
  545.      * Set note.
  546.      *
  547.      * @param string|null $note
  548.      *
  549.      * @return Address
  550.      */
  551.     public function setNote($note)
  552.     {
  553.         $this->note $note;
  554.         return $this;
  555.     }
  556.     /**
  557.      * Get note.
  558.      *
  559.      * @return string|null
  560.      */
  561.     public function getNote()
  562.     {
  563.         return $this->note;
  564.     }
  565.     /**
  566.      * Set title.
  567.      *
  568.      * @param string|null $title
  569.      *
  570.      * @return Address
  571.      */
  572.     public function setTitle($title)
  573.     {
  574.         $this->title $title;
  575.         return $this;
  576.     }
  577.     /**
  578.      * Get title.
  579.      *
  580.      * @return string|null
  581.      */
  582.     public function getTitle()
  583.     {
  584.         return $this->title;
  585.     }
  586.     /**
  587.      * Returns latitude.
  588.      *
  589.      * @return float|null
  590.      */
  591.     public function getLatitude()
  592.     {
  593.         return $this->latitude;
  594.     }
  595.     /**
  596.      * Set latitude.
  597.      *
  598.      * @param float|null $latitude
  599.      *
  600.      * @return Address
  601.      */
  602.     public function setLatitude($latitude)
  603.     {
  604.         $this->latitude $latitude;
  605.         return $this;
  606.     }
  607.     /**
  608.      * Returns longitude.
  609.      *
  610.      * @return float|null
  611.      */
  612.     public function getLongitude()
  613.     {
  614.         return $this->longitude;
  615.     }
  616.     /**
  617.      * Set longitude.
  618.      *
  619.      * @param float|null $longitude
  620.      *
  621.      * @return Address
  622.      */
  623.     public function setLongitude($longitude)
  624.     {
  625.         $this->longitude $longitude;
  626.         return $this;
  627.     }
  628. }