upgrade phonenumber on 3party: migrations

This commit is contained in:
2022-03-02 15:50:01 +01:00
parent eb6ec8a4af
commit 6a3c8017f0
3 changed files with 77 additions and 10 deletions

View File

@@ -24,6 +24,7 @@ use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use libphonenumber\PhoneNumber;
use Symfony\Component\Serializer\Annotation\Context;
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
use Symfony\Component\Serializer\Annotation\Groups;
@@ -253,14 +254,14 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
private ?ThirdPartyProfession $profession = null;
/**
* @ORM\Column(name="telephone", type="string", length=64, nullable=true)
* @ORM\Column(name="telephone", type="phone_number", nullable=true)
* @Assert\Regex("/^([\+{1}])([0-9\s*]{4,20})$/",
* message="Invalid phone number: it should begin with the international prefix starting with ""+"", hold only digits and be smaller than 20 characters. Ex: +33123456789"
* )
* @PhonenumberConstraint(type="any")
* @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"})
*/
private ?string $telephone = null;
private ?PhoneNumber $telephone = null;
/**
* @ORM\Column(name="types", type="json", nullable=true)
@@ -502,7 +503,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* Get telephone.
*/
public function getTelephone(): ?string
public function getTelephone(): ?PhoneNumber
{
return $this->telephone;
}
@@ -821,12 +822,8 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface
/**
* Set telephone.
*
* @param string|null $telephone
*
* @return ThirdParty
*/
public function setTelephone($telephone = null)
public function setTelephone(?PhoneNumber $telephone = null): self
{
$this->telephone = $telephone;