From ea66db07a448aee271c0b8fd8d5cea6f3c565b68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 24 Mar 2022 22:10:07 +0100 Subject: [PATCH] fix cs --- .../ChillActivityBundle/Form/ActivityType.php | 8 +- .../Authorization/AccompanyingPeriodVoter.php | 4 +- .../Entity/ThirdParty.php | 2 +- .../migrations/Version20220324175549.php | 86 ++++++++++--------- 4 files changed, 53 insertions(+), 47 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 3a772d878..1e1daead5 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -126,7 +126,7 @@ class ActivityType extends AbstractType if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) { $builder->add('socialIssues', HiddenType::class, [ - 'required' => $activityType->getSocialIssuesVisible() === 2 + 'required' => $activityType->getSocialIssuesVisible() === 2, ]); $builder->get('socialIssues') ->addModelTransformer(new CallbackTransformer( @@ -154,7 +154,7 @@ class ActivityType extends AbstractType if ($activityType->isVisible('socialActions') && $accompanyingPeriod) { $builder->add('socialActions', HiddenType::class, [ - 'required' => $activityType->getSocialActionsVisible() === 2 + 'required' => $activityType->getSocialActionsVisible() === 2, ]); $builder->get('socialActions') ->addModelTransformer(new CallbackTransformer( @@ -344,8 +344,8 @@ class ActivityType extends AbstractType if ($activityType->isVisible('location')) { $builder->add('location', HiddenType::class, [ - 'required' => $activityType->getLocationVisible() === 2 - ]) + 'required' => $activityType->getLocationVisible() === 2, + ]) ->get('location') ->addModelTransformer(new CallbackTransformer( static function (?Location $location): string { diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index a1166da25..9a2ee860d 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -131,8 +131,8 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH } if (in_array($attribute, [ - self::SEE, self::SEE_DETAILS, self::EDIT - ])) { + self::SEE, self::SEE_DETAILS, self::EDIT, + ], true)) { if ($subject->getUser() === $token->getUser()) { return true; } diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index d7efce10c..16260ec97 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -198,7 +198,7 @@ class ThirdParty implements TrackCreationInterface, TrackUpdateInterface private ?string $email = null; /** - * @ORM\Column(name="firstname", type="text", options={"default":""}) + * @ORM\Column(name="firstname", type="text", options={"default": ""}) * @Groups({"read", "write", "docgen:read", "docgen:read:3party:parent"}) */ private string $firstname = ''; diff --git a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php index e31b950d4..ae91699aa 100644 --- a/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php +++ b/src/Bundle/ChillThirdPartyBundle/migrations/Version20220324175549.php @@ -1,5 +1,12 @@ addSql(" + CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER + LANGUAGE plpgsql + AS + $$ + BEGIN + NEW.canonicalized = + UNACCENT( + LOWER( + NEW.name || + CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END || + COALESCE(NEW.name_company, '') || + CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END || + COALESCE(NEW.acronym, '') + ) + ) + ; + + return NEW; + END + $$ + "); + $this->addSql(" + UPDATE chill_3party.third_party + SET canonicalized = + UNACCENT( + LOWER( + name || + CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END || + COALESCE(name_company, '') || + CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END || + COALESCE(acronym, '') + ) + ) + "); + } + public function getDescription(): string { return 'indexing of firstname on third parties'; @@ -55,45 +101,5 @@ final class Version20220324175549 extends AbstractMigration END $$ "); - - } - - public function down(Schema $schema): void - { - $this->addSql(" - CREATE OR REPLACE FUNCTION chill_3party.canonicalize() RETURNS TRIGGER - LANGUAGE plpgsql - AS - $$ - BEGIN - NEW.canonicalized = - UNACCENT( - LOWER( - NEW.name || - CASE WHEN COALESCE(NEW.name_company, '') <> '' THEN ' ' ELSE '' END || - COALESCE(NEW.name_company, '') || - CASE WHEN COALESCE(NEW.acronym, '') <> '' THEN ' ' ELSE '' END || - COALESCE(NEW.acronym, '') - ) - ) - ; - - return NEW; - END - $$ - "); - $this->addSql(" - UPDATE chill_3party.third_party - SET canonicalized = - UNACCENT( - LOWER( - name || - CASE WHEN COALESCE(name_company, '') <> '' THEN ' ' ELSE '' END || - COALESCE(name_company, '') || - CASE WHEN COALESCE(acronym, '') <> '' THEN ' ' ELSE '' END || - COALESCE(acronym, '') - ) - ) - "); } }