mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add more fields to Address entity + rename streetAddress1 and streetAddress2
This commit is contained in:
parent
dd48795f64
commit
ebd58d4229
@ -28,14 +28,14 @@ class Address
|
|||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255)
|
* @ORM\Column(type="string", length=255)
|
||||||
*/
|
*/
|
||||||
private $streetAddress1 = '';
|
private $street = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*
|
*
|
||||||
* @ORM\Column(type="string", length=255)
|
* @ORM\Column(type="string", length=255)
|
||||||
*/
|
*/
|
||||||
private $streetAddress2 = '';
|
private $number = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var PostalCode
|
* @var PostalCode
|
||||||
@ -43,7 +43,56 @@ class Address
|
|||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\PostalCode")
|
||||||
*/
|
*/
|
||||||
private $postcode;
|
private $postcode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @ORM\Column(type="string", length=16, nullable=true)
|
||||||
|
*/
|
||||||
|
private $floor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @ORM\Column(type="string", length=16, nullable=true)
|
||||||
|
*/
|
||||||
|
private $corridor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @ORM\Column(type="string", length=16, nullable=true)
|
||||||
|
*/
|
||||||
|
private $steps;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
|
*/
|
||||||
|
private $buildingName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @ORM\Column(type="string", length=16, nullable=true)
|
||||||
|
*/
|
||||||
|
private $flat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
|
*/
|
||||||
|
private $distribution;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*
|
||||||
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
|
*/
|
||||||
|
private $extra;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates when the address starts validation. Used to build an history
|
* Indicates when the address starts validation. Used to build an history
|
||||||
* of address. By default, the current date.
|
* of address. By default, the current date.
|
||||||
@ -53,21 +102,31 @@ class Address
|
|||||||
* @ORM\Column(type="date")
|
* @ORM\Column(type="date")
|
||||||
*/
|
*/
|
||||||
private $validFrom;
|
private $validFrom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates when the address ends. Used to build an history
|
||||||
|
* of address.
|
||||||
|
*
|
||||||
|
* @var \DateTime
|
||||||
|
*
|
||||||
|
* @ORM\Column(type="date")
|
||||||
|
*/
|
||||||
|
private $validTo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if the address is a "no address", aka homeless person, ...
|
* True if the address is a "no address", aka homeless person, ...
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $isNoAddress = false;
|
private $isNoAddress = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of metadata, added by customizable fields
|
* A list of metadata, added by customizable fields
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $customs = [];
|
private $customs = [];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->validFrom = new \DateTime();
|
$this->validFrom = new \DateTime();
|
||||||
@ -105,7 +164,7 @@ class Address
|
|||||||
*/
|
*/
|
||||||
public function getStreetAddress1()
|
public function getStreetAddress1()
|
||||||
{
|
{
|
||||||
return $this->streetAddress1;
|
return $this->street;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,7 +188,7 @@ class Address
|
|||||||
*/
|
*/
|
||||||
public function getStreetAddress2()
|
public function getStreetAddress2()
|
||||||
{
|
{
|
||||||
return $this->streetAddress2;
|
return $this->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -155,7 +214,7 @@ class Address
|
|||||||
{
|
{
|
||||||
return $this->postcode;
|
return $this->postcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \DateTime
|
* @return \DateTime
|
||||||
*/
|
*/
|
||||||
@ -173,19 +232,19 @@ class Address
|
|||||||
$this->validFrom = $validFrom;
|
$this->validFrom = $validFrom;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get IsNoAddress
|
* Get IsNoAddress
|
||||||
*
|
*
|
||||||
* Indicate true if the address is a fake address (homeless, ...)
|
* Indicate true if the address is a fake address (homeless, ...)
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function getIsNoAddress(): bool
|
public function getIsNoAddress(): bool
|
||||||
{
|
{
|
||||||
return $this->isNoAddress;
|
return $this->isNoAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
@ -196,9 +255,9 @@ class Address
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set IsNoAddress
|
* Set IsNoAddress
|
||||||
*
|
*
|
||||||
* Indicate true if the address is a fake address (homeless, ...)
|
* Indicate true if the address is a fake address (homeless, ...)
|
||||||
*
|
*
|
||||||
* @param bool $isNoAddress
|
* @param bool $isNoAddress
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
@ -207,10 +266,10 @@ class Address
|
|||||||
$this->isNoAddress = $isNoAddress;
|
$this->isNoAddress = $isNoAddress;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get customs informations in the address
|
* Get customs informations in the address
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getCustoms(): array
|
public function getCustoms(): array
|
||||||
@ -220,27 +279,27 @@ class Address
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Store custom informations in the address
|
* Store custom informations in the address
|
||||||
*
|
*
|
||||||
* @param array $customs
|
* @param array $customs
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setCustoms(array $customs): self
|
public function setCustoms(array $customs): self
|
||||||
{
|
{
|
||||||
$this->customs = $customs;
|
$this->customs = $customs;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate the address.
|
* Validate the address.
|
||||||
*
|
*
|
||||||
* Check that:
|
* Check that:
|
||||||
*
|
*
|
||||||
* * if the address is not home address:
|
* * if the address is not home address:
|
||||||
* * the postal code is present
|
* * the postal code is present
|
||||||
* * the valid from is not null
|
* * the valid from is not null
|
||||||
* * the address street 1 is greater than 2
|
* * the address street 1 is greater than 2
|
||||||
*
|
*
|
||||||
* @param ExecutionContextInterface $context
|
* @param ExecutionContextInterface $context
|
||||||
* @param array $payload
|
* @param array $payload
|
||||||
*/
|
*/
|
||||||
@ -252,18 +311,18 @@ class Address
|
|||||||
->atPath('validFrom')
|
->atPath('validFrom')
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isNoAddress()) {
|
if ($this->isNoAddress()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->getStreetAddress1())) {
|
if (empty($this->getStreetAddress1())) {
|
||||||
$context
|
$context
|
||||||
->buildViolation("address.street1-should-be-set")
|
->buildViolation("address.street1-should-be-set")
|
||||||
->atPath('streetAddress1')
|
->atPath('streetAddress1')
|
||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->getPostcode() instanceof PostalCode) {
|
if (!$this->getPostcode() instanceof PostalCode) {
|
||||||
$context
|
$context
|
||||||
->buildViolation("address.postcode-should-be-set")
|
->buildViolation("address.postcode-should-be-set")
|
||||||
@ -271,7 +330,7 @@ class Address
|
|||||||
->addViolation();
|
->addViolation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Address $original
|
* @param Address $original
|
||||||
* @return Address
|
* @return Address
|
||||||
@ -286,5 +345,125 @@ class Address
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getStreet(): ?string
|
||||||
|
{
|
||||||
|
return $this->street;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setStreet(string $street): self
|
||||||
|
{
|
||||||
|
$this->street = $street;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNumber(): ?string
|
||||||
|
{
|
||||||
|
return $this->number;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNumber(string $number): self
|
||||||
|
{
|
||||||
|
$this->number = $number;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFloor(): ?string
|
||||||
|
{
|
||||||
|
return $this->floor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFloor(?string $floor): self
|
||||||
|
{
|
||||||
|
$this->floor = $floor;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCorridor(): ?string
|
||||||
|
{
|
||||||
|
return $this->corridor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCorridor(?string $corridor): self
|
||||||
|
{
|
||||||
|
$this->corridor = $corridor;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSteps(): ?string
|
||||||
|
{
|
||||||
|
return $this->steps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setSteps(?string $steps): self
|
||||||
|
{
|
||||||
|
$this->steps = $steps;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getBuildingName(): ?string
|
||||||
|
{
|
||||||
|
return $this->buildingName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setBuildingName(?string $buildingName): self
|
||||||
|
{
|
||||||
|
$this->buildingName = $buildingName;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFlat(): ?string
|
||||||
|
{
|
||||||
|
return $this->flat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFlat(?string $flat): self
|
||||||
|
{
|
||||||
|
$this->flat = $flat;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDistribution(): ?string
|
||||||
|
{
|
||||||
|
return $this->distribution;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setDistribution(?string $distribution): self
|
||||||
|
{
|
||||||
|
$this->distribution = $distribution;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getExtra(): ?string
|
||||||
|
{
|
||||||
|
return $this->extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setExtra(?string $extra): self
|
||||||
|
{
|
||||||
|
$this->extra = $extra;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getValidTo(): ?\DateTimeInterface
|
||||||
|
{
|
||||||
|
return $this->validTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setValidTo(\DateTimeInterface $validTo): self
|
||||||
|
{
|
||||||
|
$this->validTo = $validTo;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user