diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 9a8555d8e..4de44e40e 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -37,6 +37,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Mapping as ORM; use Exception; +use libphonenumber\PhoneNumber; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; @@ -371,12 +372,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI /** * The person's mobile phone number. * - * @ORM\Column(type="text") - * @PhonenumberConstraint( - * type="mobile", - * ) + * @ORM\Column(type="phone_number") */ - private string $mobilenumber = ''; + private ?PhoneNumber $mobilenumber; /** * The person's nationality. @@ -426,12 +424,9 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI /** * The person's phonenumber. * - * @ORM\Column(type="text", nullable=true) - * @PhonenumberConstraint( - * type="landline", - * ) + * @ORM\Column(type="phone_number") */ - private ?string $phonenumber = null; + private ?PhoneNumber $phonenumber; /** * The person's place of birth. diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 4fc078cf1..05f5aa562 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -31,8 +31,9 @@ use Chill\PersonBundle\Form\Type\Select2MaritalStatusType; use Doctrine\ORM\EntityRepository; use Doctrine\ORM\QueryBuilder; use libphonenumber\PhoneNumberFormat; -use libphonenumber\PhoneNumberType; +use libphonenumber\PhoneNumberType as LibphonenumberPhoneNumberType; use libphonenumber\PhoneNumberUtil; +use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\Form\AbstractType; @@ -41,7 +42,6 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType; use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Extension\Core\Type\EmailType; use Symfony\Component\Form\Extension\Core\Type\IntegerType; -use Symfony\Component\Form\Extension\Core\Type\TelType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -141,14 +141,16 @@ class PersonType extends AbstractType $examplePhoneNumber = PhoneNumberUtil::getInstance() ->getExampleNumberForType( $this->parameterBag->get('chill_main.phone_helper')['default_carrier_code'], - PhoneNumberType::FIXED_LINE + LibphonenumberPhoneNumberType::FIXED_LINE ); $builder ->add( 'phonenumber', - TelType::class, + PhoneNumberType::class, [ + 'default_region' => $this->parameterBag->get('chill_main.phone_helper')['default_carrier_code'], + 'format' => PhoneNumberFormat::NATIONAL, 'required' => false, 'attr' => [ 'placeholder' => PhoneNumberUtil::getInstance()->format($examplePhoneNumber, PhoneNumberFormat::NATIONAL) @@ -161,14 +163,16 @@ class PersonType extends AbstractType $examplePhoneNumber = PhoneNumberUtil::getInstance() ->getExampleNumberForType( $this->parameterBag->get('chill_main.phone_helper')['default_carrier_code'], - PhoneNumberType::MOBILE + LibphonenumberPhoneNumberType::MOBILE ); $builder ->add( 'mobilenumber', - TelType::class, + PhoneNumberType::class, [ + 'default_region' => $this->parameterBag->get('chill_main.phone_helper')['default_carrier_code'], + 'format' => PhoneNumberFormat::NATIONAL, 'required' => false, 'attr' => [ 'placeholder' => PhoneNumberUtil::getInstance()->format($examplePhoneNumber, PhoneNumberFormat::NATIONAL)