Use new PhoneNumber form type.

This commit is contained in:
Pol Dellaiera
2021-05-19 21:22:46 +02:00
parent 348f649fef
commit c9eaf3afac
4 changed files with 133 additions and 130 deletions

View File

@@ -368,19 +368,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
private $memo = ''; // TO-CHANGE in remark
/**
* The person's mobile phone number.
*
* @ORM\Column(type="text")
* @Assert\Regex(
* pattern="/^([\+{1}])([0-9\s*]{4,20})$/",
* )
* @PhonenumberConstraint(
* type="mobile",
* )
*/
private string $mobilenumber = '';
/**
* The person's nationality.
*
@@ -403,6 +390,24 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
private ?int $numberOfChildren = null;
/**
* @ORM\Column(type="phone_number", nullable=true)
* @PhonenumberConstraint(
* type="landline",
* groups={"general", "creation"}
* )
*/
private ?PhoneNumber $phonenumber;
/**
* @ORM\Column(type="phone_number", nullable=true)
* @PhonenumberConstraint(
* type="mobile",
* groups={"general", "creation"}
* )
*/
private ?PhoneNumber $mobilenumber;
/**
* @var Collection
*
@@ -426,19 +431,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
*/
private Collection $periodLocatedOn;
/**
* The person's phonenumber.
*
* @ORM\Column(type="text")
* @Assert\Regex(
* pattern="/^([\+{1}])([0-9\s*]{4,20})$/",
* )
* @PhonenumberConstraint(
* type="landline",
* )
*/
private string $phonenumber = '';
/**
* The person's place of birth.
*
@@ -510,7 +502,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
}
/**
* Add AccompanyingPeriodParticipation.
* Add AccompanyingPeriodParticipation
*
* @uses AccompanyingPeriod::addPerson
*/
@@ -522,6 +514,22 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
/**
* set the Person file as open at the given date.
*
* For updating a opening's date, you should update AccompanyingPeriod instance
* directly.
*
* For closing a file, @see this::close
*
* To check if the Person and its accompanying period is consistent, use validation.
*/
public function open(AccompanyingPeriod $accompanyingPeriod) : void
{
$this->proxyAccompanyingPeriodOpenState = true;
$this->addAccompanyingPeriod($accompanyingPeriod);
}
/**
* @return $this
*/
@@ -552,7 +560,32 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
public function setPhonenumber(?PhoneNumber $phonenumber = null): self
{
$this->phonenumber = $phonenumber;
return $this;
}
public function getPhonenumber(): ?PhoneNumber
{
return $this->phonenumber;
}
public function setMobilenumber(?PhoneNumber $mobilenumber = null): self
{
$this->mobilenumber = $mobilenumber;
return $this;
}
public function getMobilenumber(): ?PhoneNumber
{
return $this->mobilenumber;
}
/**
* @param PersonPhone $otherPhoneNumber
* @return $this
*/
public function addOtherPhoneNumber(PersonPhone $otherPhoneNumber)
@@ -1225,14 +1258,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->memo;
}
/**
* Get mobilenumber.
*/
public function getMobilenumber(): string
{
return $this->mobilenumber;
}
/**
* Get nationality.
*
@@ -1293,14 +1318,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this->otherPhoneNumbers;
}
/**
* Get phonenumber.
*/
public function getPhonenumber(): string
{
return $this->phonenumber;
}
/**
* Get placeOfBirth.
*
@@ -1423,22 +1440,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return null !== $this->getCurrentHousehold($at);
}
/**
* set the Person file as open at the given date.
*
* For updating a opening's date, you should update AccompanyingPeriod instance
* directly.
*
* For closing a file, @see this::close
*
* To check if the Person and its accompanying period is consistent, use validation.
*/
public function open(AccompanyingPeriod $accompanyingPeriod): void
{
$this->proxyAccompanyingPeriodOpenState = true;
$this->addAccompanyingPeriod($accompanyingPeriod);
}
/**
* Remove AccompanyingPeriod.
*/
@@ -1735,20 +1736,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
/**
* Set mobilenumber.
*
* @param string $mobilenumber
*
* @return Person
*/
public function setMobilenumber(?string $mobilenumber = '')
{
$this->mobilenumber = (string) $mobilenumber;
return $this;
}
/**
* Set nationality.
*
@@ -1780,20 +1767,6 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
return $this;
}
/**
* Set phonenumber.
*
* @param string $phonenumber
*
* @return Person
*/
public function setPhonenumber(?string $phonenumber = '')
{
$this->phonenumber = (string) $phonenumber;
return $this;
}
/**
* Set placeOfBirth.
*