diff --git a/src/Bundle/ChillMainBundle/Entity/Location.php b/src/Bundle/ChillMainBundle/Entity/Location.php index bff3ff37b..437ac1714 100644 --- a/src/Bundle/ChillMainBundle/Entity/Location.php +++ b/src/Bundle/ChillMainBundle/Entity/Location.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Validation\Constraint\PhonenumberConstraint; use DateTimeImmutable; use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; +use libphonenumber\PhoneNumber; use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Validator\Constraints as Assert; @@ -90,20 +91,18 @@ class Location implements TrackCreationInterface, TrackUpdateInterface private ?string $name = null; /** - * @ORM\Column(type="string", length=64, nullable=true) + * @ORM\Column(type="phone_number") * @Serializer\Groups({"read", "write", "docgen:read"}) - * @Assert\Regex(pattern="/^([\+{1}])([0-9\s*]{4,20})$/") * @PhonenumberConstraint(type="any") */ - private ?string $phonenumber1 = null; + private ?PhoneNumber $phonenumber1 = null; /** - * @ORM\Column(type="string", length=64, nullable=true) + * @ORM\Column(type="phone_number") * @Serializer\Groups({"read", "write", "docgen:read"}) - * @Assert\Regex(pattern="/^([\+{1}])([0-9\s*]{4,20})$/") * @PhonenumberConstraint(type="any") */ - private ?string $phonenumber2 = null; + private ?PhoneNumber $phonenumber2 = null; /** * @ORM\Column(type="datetime_immutable", nullable=true) @@ -162,12 +161,12 @@ class Location implements TrackCreationInterface, TrackUpdateInterface return $this->name; } - public function getPhonenumber1(): ?string + public function getPhonenumber1(): ?PhoneNumber { return $this->phonenumber1; } - public function getPhonenumber2(): ?string + public function getPhonenumber2(): ?PhoneNumber { return $this->phonenumber2; } @@ -238,14 +237,14 @@ class Location implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setPhonenumber1(?string $phonenumber1): self + public function setPhonenumber1(?PhoneNumber $phonenumber1): self { $this->phonenumber1 = $phonenumber1; return $this; } - public function setPhonenumber2(?string $phonenumber2): self + public function setPhonenumber2(?PhoneNumber $phonenumber2): self { $this->phonenumber2 = $phonenumber2; diff --git a/src/Bundle/ChillMainBundle/Form/LocationFormType.php b/src/Bundle/ChillMainBundle/Form/LocationFormType.php index 713705de3..de10e88a5 100644 --- a/src/Bundle/ChillMainBundle/Form/LocationFormType.php +++ b/src/Bundle/ChillMainBundle/Form/LocationFormType.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Chill\MainBundle\Form; use Chill\MainBundle\Entity\LocationType as EntityLocationType; +use Chill\MainBundle\Form\Type\ChillPhoneNumberType; use Chill\MainBundle\Form\Type\PickAddressType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Symfony\Bridge\Doctrine\Form\Type\EntityType; @@ -46,8 +47,8 @@ final class LocationFormType extends AbstractType }, ]) ->add('name', TextType::class) - ->add('phonenumber1', TextType::class, ['required' => false]) - ->add('phonenumber2', TextType::class, ['required' => false]) + ->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false]) + ->add('phonenumber2',ChillPhoneNumberType::class, ['required' => false]) ->add('email', TextType::class, ['required' => false]) ->add('address', PickAddressType::class, [ 'required' => false, diff --git a/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig index bc39a9275..a04ae73a9 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Location/index.html.twig @@ -18,8 +18,10 @@ {% for entity in entities %}