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

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