From 02d8ceba259d3cc320e338507d2634ba015c405f Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 24 Jan 2022 10:42:05 +0100 Subject: [PATCH] address: add confidential in normalizer + code style fix --- src/Bundle/ChillMainBundle/Entity/Address.php | 10 +++++----- .../Normalizer/AddressNormalizer.php | 2 ++ .../migrations/Version20220124085957.php | 20 +++++++++---------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index 3a35abb94..ef965f062 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -238,16 +238,16 @@ class Address return $this->buildingName; } - public function getCorridor(): ?string - { - return $this->corridor; - } - public function getConfidential(): bool { return $this->confidential; } + public function getCorridor(): ?string + { + return $this->corridor; + } + /** * Get customs informations in the address. */ diff --git a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php index 0b46127b6..10e889344 100644 --- a/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php +++ b/src/Bundle/ChillMainBundle/Serializer/Normalizer/AddressNormalizer.php @@ -45,6 +45,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw 'extra', 'validFrom' => DateTimeInterface::class, 'validTo' => DateTimeInterface::class, + 'confidential', ]; private AddressRender $addressRender; @@ -83,6 +84,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw 'buildingName' => $address->getBuildingName(), 'distribution' => $address->getDistribution(), 'extra' => $address->getExtra(), + 'confidential' => $address->getConfidential(), 'lines' => $this->addressRender->renderLines($address), ]; diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220124085957.php b/src/Bundle/ChillMainBundle/migrations/Version20220124085957.php index d1b8d6739..17b58825d 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20220124085957.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20220124085957.php @@ -15,10 +15,19 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; /** - * Alter some address fields + add confidential field on Address + * Alter some address fields + add confidential field on Address. */ final class Version20220124085957 extends AbstractMigration { + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_address DROP confidential'); + $this->addSql('ALTER TABLE chill_main_address ALTER corridor TYPE VARCHAR(16)'); + $this->addSql('ALTER TABLE chill_main_address ALTER flat TYPE VARCHAR(16)'); + $this->addSql('ALTER TABLE chill_main_address ALTER floor TYPE VARCHAR(16)'); + $this->addSql('ALTER TABLE chill_main_address ALTER steps TYPE VARCHAR(16)'); + } + public function getDescription(): string { return 'Alter some address fields + add confidential field on Address'; @@ -32,13 +41,4 @@ final class Version20220124085957 extends AbstractMigration $this->addSql('ALTER TABLE chill_main_address ALTER steps TYPE TEXT'); $this->addSql('ALTER TABLE chill_main_address ALTER flat TYPE TEXT'); } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE chill_main_address DROP confidential'); - $this->addSql('ALTER TABLE chill_main_address ALTER corridor TYPE VARCHAR(16)'); - $this->addSql('ALTER TABLE chill_main_address ALTER flat TYPE VARCHAR(16)'); - $this->addSql('ALTER TABLE chill_main_address ALTER floor TYPE VARCHAR(16)'); - $this->addSql('ALTER TABLE chill_main_address ALTER steps TYPE VARCHAR(16)'); - } }