mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix cs
This commit is contained in:
parent
5ce62f5458
commit
15bc3e62d3
@ -21,7 +21,6 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
use libphonenumber\PhoneNumber;
|
use libphonenumber\PhoneNumber;
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Table(name="chill_main_location")
|
* @ORM\Table(name="chill_main_location")
|
||||||
|
@ -48,7 +48,7 @@ final class LocationFormType extends AbstractType
|
|||||||
])
|
])
|
||||||
->add('name', TextType::class)
|
->add('name', TextType::class)
|
||||||
->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false])
|
->add('phonenumber1', ChillPhoneNumberType::class, ['required' => false])
|
||||||
->add('phonenumber2',ChillPhoneNumberType::class, ['required' => false])
|
->add('phonenumber2', ChillPhoneNumberType::class, ['required' => false])
|
||||||
->add('email', TextType::class, ['required' => false])
|
->add('email', TextType::class, ['required' => false])
|
||||||
->add('address', PickAddressType::class, [
|
->add('address', PickAddressType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
@ -1,15 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\MainBundle\Form\Type;
|
namespace Chill\MainBundle\Form\Type;
|
||||||
|
|
||||||
use libphonenumber\PhoneNumberFormat;
|
use libphonenumber\PhoneNumberFormat;
|
||||||
use libphonenumber\PhoneNumberUtil;
|
use libphonenumber\PhoneNumberUtil;
|
||||||
use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType;
|
use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType;
|
||||||
use libphonenumber\PhoneNumberType as LibphonenumberPhoneNumberType;
|
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\OptionsResolver\Options;
|
use Symfony\Component\OptionsResolver\Options;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use function array_key_exists;
|
||||||
|
|
||||||
class ChillPhoneNumberType extends AbstractType
|
class ChillPhoneNumberType extends AbstractType
|
||||||
{
|
{
|
||||||
@ -29,7 +38,7 @@ class ChillPhoneNumberType extends AbstractType
|
|||||||
->setDefault('default_region', $this->defaultCarrierCode)
|
->setDefault('default_region', $this->defaultCarrierCode)
|
||||||
->setDefault('format', PhoneNumberFormat::NATIONAL)
|
->setDefault('format', PhoneNumberFormat::NATIONAL)
|
||||||
->setDefault('type', \libphonenumber\PhoneNumberType::FIXED_LINE_OR_MOBILE)
|
->setDefault('type', \libphonenumber\PhoneNumberType::FIXED_LINE_OR_MOBILE)
|
||||||
->setNormalizer('attr', function(Options $options, $value) {
|
->setNormalizer('attr', function (Options $options, $value) {
|
||||||
if (array_key_exists('placeholder', $value)) {
|
if (array_key_exists('placeholder', $value)) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
@ -49,5 +58,4 @@ class ChillPhoneNumberType extends AbstractType
|
|||||||
{
|
{
|
||||||
return PhoneNumberType::class;
|
return PhoneNumberType::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,5 +51,4 @@ interface PhoneNumberHelperInterface
|
|||||||
* if the validation is not configured.
|
* if the validation is not configured.
|
||||||
*/
|
*/
|
||||||
public function isValidPhonenumberMobile(string $phonenumber): bool;
|
public function isValidPhonenumberMobile(string $phonenumber): bool;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ use GuzzleHttp\Exception\ConnectException;
|
|||||||
use GuzzleHttp\Exception\ServerException;
|
use GuzzleHttp\Exception\ServerException;
|
||||||
use libphonenumber\NumberParseException;
|
use libphonenumber\NumberParseException;
|
||||||
use libphonenumber\PhoneNumber;
|
use libphonenumber\PhoneNumber;
|
||||||
use libphonenumber\PhoneNumberFormat;
|
|
||||||
use libphonenumber\PhoneNumberUtil;
|
use libphonenumber\PhoneNumberUtil;
|
||||||
use Psr\Cache\CacheItemPoolInterface;
|
use Psr\Cache\CacheItemPoolInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
@ -12,7 +12,6 @@ declare(strict_types=1);
|
|||||||
namespace Chill\MainBundle\Tests\Routing\Loader;
|
namespace Chill\MainBundle\Tests\Routing\Loader;
|
||||||
|
|
||||||
use Chill\MainBundle\Phonenumber\PhonenumberHelper;
|
use Chill\MainBundle\Phonenumber\PhonenumberHelper;
|
||||||
use libphonenumber\PhoneNumber;
|
|
||||||
use libphonenumber\PhoneNumberUtil;
|
use libphonenumber\PhoneNumberUtil;
|
||||||
use Psr\Log\NullLogger;
|
use Psr\Log\NullLogger;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\Migrations\Main;
|
namespace Chill\Migrations\Main;
|
||||||
@ -7,6 +14,7 @@ namespace Chill\Migrations\Main;
|
|||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
use libphonenumber\PhoneNumberUtil;
|
use libphonenumber\PhoneNumberUtil;
|
||||||
|
use RuntimeException;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||||
|
|
||||||
@ -14,6 +22,16 @@ final class Version20220302132728 extends AbstractMigration implements Container
|
|||||||
{
|
{
|
||||||
use ContainerAwareTrait;
|
use ContainerAwareTrait;
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber1 TYPE VARCHAR(64)');
|
||||||
|
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber1 DROP DEFAULT');
|
||||||
|
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber2 TYPE VARCHAR(64)');
|
||||||
|
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber2 DROP DEFAULT');
|
||||||
|
$this->addSql('COMMENT ON COLUMN chill_main_location.phonenumber1 IS NULL');
|
||||||
|
$this->addSql('COMMENT ON COLUMN chill_main_location.phonenumber2 IS NULL');
|
||||||
|
}
|
||||||
|
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'Upgrade phonenumber on location';
|
return 'Upgrade phonenumber on location';
|
||||||
@ -25,7 +43,7 @@ final class Version20220302132728 extends AbstractMigration implements Container
|
|||||||
->getParameter('chill_main')['phone_helper']['default_carrier_code'];
|
->getParameter('chill_main')['phone_helper']['default_carrier_code'];
|
||||||
|
|
||||||
if (null === $carrier_code) {
|
if (null === $carrier_code) {
|
||||||
throw new \RuntimeException('no carrier code');
|
throw new RuntimeException('no carrier code');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber1 TYPE VARCHAR(35)');
|
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber1 TYPE VARCHAR(35)');
|
||||||
@ -45,16 +63,6 @@ final class Version20220302132728 extends AbstractMigration implements Container
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber1 TYPE VARCHAR(64)');
|
|
||||||
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber1 DROP DEFAULT');
|
|
||||||
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber2 TYPE VARCHAR(64)');
|
|
||||||
$this->addSql('ALTER TABLE chill_main_location ALTER phonenumber2 DROP DEFAULT');
|
|
||||||
$this->addSql('COMMENT ON COLUMN chill_main_location.phonenumber1 IS NULL');
|
|
||||||
$this->addSql('COMMENT ON COLUMN chill_main_location.phonenumber2 IS NULL');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildMigrationPhoneNumberClause(string $defaultCarriercode, string $field): string
|
private function buildMigrationPhoneNumberClause(string $defaultCarriercode, string $field): string
|
||||||
{
|
{
|
||||||
$util = PhoneNumberUtil::getInstance();
|
$util = PhoneNumberUtil::getInstance();
|
||||||
|
@ -25,7 +25,6 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TelType;
|
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
|
||||||
@ -64,7 +63,7 @@ final class CreationPersonType extends AbstractType
|
|||||||
])
|
])
|
||||||
->add('phonenumber', ChillPhoneNumberType::class, [
|
->add('phonenumber', ChillPhoneNumberType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'type' => PhoneNumberType::FIXED_LINE
|
'type' => PhoneNumberType::FIXED_LINE,
|
||||||
])
|
])
|
||||||
->add('mobilenumber', ChillPhoneNumberType::class, [
|
->add('mobilenumber', ChillPhoneNumberType::class, [
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
@ -27,12 +27,7 @@ use Chill\PersonBundle\Entity\Person;
|
|||||||
use Chill\PersonBundle\Entity\PersonPhone;
|
use Chill\PersonBundle\Entity\PersonPhone;
|
||||||
use Chill\PersonBundle\Form\Type\GenderType;
|
use Chill\PersonBundle\Form\Type\GenderType;
|
||||||
use Chill\PersonBundle\Form\Type\PersonAltNameType;
|
use Chill\PersonBundle\Form\Type\PersonAltNameType;
|
||||||
use Chill\PersonBundle\Form\Type\PersonPhoneType;
|
|
||||||
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
use Chill\PersonBundle\Form\Type\Select2MaritalStatusType;
|
||||||
use libphonenumber\PhoneNumberFormat;
|
|
||||||
use libphonenumber\PhoneNumberType as LibphonenumberPhoneNumberType;
|
|
||||||
use libphonenumber\PhoneNumberUtil;
|
|
||||||
use Misd\PhoneNumberBundle\Form\Type\PhoneNumberType;
|
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Chill is a software for social workers
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view
|
||||||
|
* the LICENSE file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Chill\Migrations\ThirdParty;
|
namespace Chill\Migrations\ThirdParty;
|
||||||
@ -7,6 +14,7 @@ namespace Chill\Migrations\ThirdParty;
|
|||||||
use Doctrine\DBAL\Schema\Schema;
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
use Doctrine\Migrations\AbstractMigration;
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
use libphonenumber\PhoneNumberUtil;
|
use libphonenumber\PhoneNumberUtil;
|
||||||
|
use RuntimeException;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||||
|
|
||||||
@ -14,11 +22,38 @@ final class Version20220302143821 extends AbstractMigration implements Container
|
|||||||
{
|
{
|
||||||
use ContainerAwareTrait;
|
use ContainerAwareTrait;
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->addSql('ALTER TABLE chill_3party.third_party ALTER telephone TYPE VARCHAR(64)');
|
||||||
|
$this->addSql('ALTER TABLE chill_3party.third_party ALTER telephone DROP DEFAULT');
|
||||||
|
$this->addSql('COMMENT ON COLUMN chill_3party.third_party.telephone IS NULL');
|
||||||
|
}
|
||||||
|
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'Upgrade phonenumber on third parties';
|
return 'Upgrade phonenumber on third parties';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$carrier_code = $this->container
|
||||||
|
->getParameter('chill_main')['phone_helper']['default_carrier_code'];
|
||||||
|
|
||||||
|
if (null === $carrier_code) {
|
||||||
|
throw new RuntimeException('no carrier code');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addSql('ALTER TABLE chill_3party.third_party ALTER telephone TYPE VARCHAR(35)');
|
||||||
|
$this->addSql('ALTER TABLE chill_3party.third_party ALTER telephone DROP DEFAULT');
|
||||||
|
$this->addSql('ALTER TABLE chill_3party.third_party ALTER telephone TYPE VARCHAR(35)');
|
||||||
|
$this->addSql('COMMENT ON COLUMN chill_3party.third_party.telephone IS \'(DC2Type:phone_number)\'');
|
||||||
|
|
||||||
|
$this->addSql(
|
||||||
|
'UPDATE chill_3party.third_party SET ' .
|
||||||
|
$this->buildMigrationPhonenumberClause($carrier_code, 'telephone')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private function buildMigrationPhoneNumberClause(string $defaultCarriercode, string $field): string
|
private function buildMigrationPhoneNumberClause(string $defaultCarriercode, string $field): string
|
||||||
{
|
{
|
||||||
$util = PhoneNumberUtil::getInstance();
|
$util = PhoneNumberUtil::getInstance();
|
||||||
@ -32,31 +67,4 @@ final class Version20220302143821 extends AbstractMigration implements Container
|
|||||||
ELSE replace(replace(%s, \'(0)\', \'\'),\' \', \'\')
|
ELSE replace(replace(%s, \'(0)\', \'\'),\' \', \'\')
|
||||||
END', $field, $field, $field, $countryCode, $field, $field);
|
END', $field, $field, $field, $countryCode, $field, $field);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function up(Schema $schema): void
|
|
||||||
{
|
|
||||||
$carrier_code = $this->container
|
|
||||||
->getParameter('chill_main')['phone_helper']['default_carrier_code'];
|
|
||||||
|
|
||||||
if (null === $carrier_code) {
|
|
||||||
throw new \RuntimeException('no carrier code');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->addSql('ALTER TABLE chill_3party.third_party ALTER telephone TYPE VARCHAR(35)');
|
|
||||||
$this->addSql('ALTER TABLE chill_3party.third_party ALTER telephone DROP DEFAULT');
|
|
||||||
$this->addSql('ALTER TABLE chill_3party.third_party ALTER telephone TYPE VARCHAR(35)');
|
|
||||||
$this->addSql('COMMENT ON COLUMN chill_3party.third_party.telephone IS \'(DC2Type:phone_number)\'');
|
|
||||||
|
|
||||||
$this->addSql(
|
|
||||||
'UPDATE chill_3party.third_party SET ' .
|
|
||||||
$this->buildMigrationPhonenumberClause($carrier_code, 'telephone')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function down(Schema $schema): void
|
|
||||||
{
|
|
||||||
$this->addSql('ALTER TABLE chill_3party.third_party ALTER telephone TYPE VARCHAR(64)');
|
|
||||||
$this->addSql('ALTER TABLE chill_3party.third_party ALTER telephone DROP DEFAULT');
|
|
||||||
$this->addSql('COMMENT ON COLUMN chill_3party.third_party.telephone IS NULL');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user