diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php
index 4db8abe9b..62362956b 100644
--- a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php
+++ b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php
@@ -60,9 +60,6 @@ class AddressRender implements ChillEntityRenderInterface
}
/**
- * @param Address addr
- * @param mixed $addr
- *
* @return string[]
*/
public function renderLines(Address $addr, bool $includeCityLine = true, bool $includeCountry = true): array
@@ -98,18 +95,18 @@ class AddressRender implements ChillEntityRenderInterface
}
}
- return array_values(array_filter($lines, static fn ($l) => null !== $l));
+ return array_values(array_filter($lines, static fn ($l) => '' !== (string) $l));
}
public function renderStreetLine(Address $addr): ?string
{
- if (null !== $addr->getStreet() && $addr->getStreet() !== '') {
+ if ('' !== $addr->getStreet()) {
$street = $addr->getStreet();
} else {
$street = '';
}
- if (null !== $addr->getStreetNumber() && $addr->getStreetNumber() !== '') {
+ if ('' !== $addr->getStreetNumber()) {
$streetNumber = $addr->getStreetNumber();
} else {
$streetNumber = '';
@@ -146,7 +143,7 @@ class AddressRender implements ChillEntityRenderInterface
private function renderBuildingLine(Address $addr): ?string
{
- if (null !== $addr->getBuildingName() && $addr->getBuildingName() !== '') {
+ if ($addr->getBuildingName() !== '') {
$building = $addr->getBuildingName();
} else {
$building = '';
@@ -172,7 +169,7 @@ class AddressRender implements ChillEntityRenderInterface
return $res;
}
- private function renderCityLine($addr): string
+ private function renderCityLine(Address $addr): string
{
if (null !== $addr->getPostcode()) {
$res = strtr('{postcode} {label}', [
@@ -180,11 +177,9 @@ class AddressRender implements ChillEntityRenderInterface
'{label}' => $addr->getPostcode()->getName(),
]);
- if (null !== $addr->getPostCode()->getCountry()->getCountryCode()) {
- if ($addr->getPostCode()->getCountry()->getCountryCode() === 'FR') {
- if ($addr->getDistribution()) {
- $res = $res . ' ' . $addr->getDistribution();
- }
+ if ($addr->getPostcode()->getCountry()->getCountryCode() === 'FR') {
+ if ('' !== $addr->getDistribution()) {
+ $res = $res . ' ' . $addr->getDistribution();
}
}
}
@@ -192,35 +187,35 @@ class AddressRender implements ChillEntityRenderInterface
return $res ?? '';
}
- private function renderCountryLine($addr): ?string
+ private function renderCountryLine(Address $addr): ?string
{
return $this->translatableStringHelper->localize(
- $addr->getPostCode()->getCountry()->getName()
+ $addr->getPostcode()->getCountry()->getName()
);
}
- private function renderDeliveryLine($addr): ?string
+ private function renderDeliveryLine(Address $addr): string
{
return $addr->getExtra();
}
- private function renderIntraBuildingLine($addr): ?string
+ private function renderIntraBuildingLine(Address $addr): ?string
{
$arr = [];
- if ($addr->getFlat()) {
+ if ('' !== $addr->getFlat()) {
$arr[] = 'appart ' . $addr->getFlat();
}
- if ($addr->getFloor()) {
+ if ('' !== $addr->getFloor()) {
$arr[] = 'ét ' . $addr->getFloor();
}
- if ($addr->getCorridor()) {
+ if ('' !== $addr->getCorridor()) {
$arr[] = 'coul ' . $addr->getCorridor();
}
- if ($addr->getSteps()) {
+ if ('' !== $addr->getSteps()) {
$arr[] = 'esc ' . $addr->getSteps();
}
diff --git a/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php
index 3c14020d5..2ef7f0143 100644
--- a/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php
+++ b/src/Bundle/ChillMainBundle/Tests/Services/Import/AddressReferenceBaseImporterTest.php
@@ -99,7 +99,7 @@ final class AddressReferenceBaseImporterTest extends KernelTestCase
'abcc guessed fixed'
);
- $this->assertCount('1', $addresses);
+ $this->assertCount(1, $addresses);
$this->assertEquals('Rue test abccc guessed fixed', $addresses[0]->getStreet());
$this->assertEquals($previousAddressId, $addresses[0]->getId());
}
diff --git a/src/Bundle/ChillMainBundle/migrations/Version20230306145728.php b/src/Bundle/ChillMainBundle/migrations/Version20230306145728.php
new file mode 100644
index 000000000..a5e1ffa6f
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/migrations/Version20230306145728.php
@@ -0,0 +1,109 @@
+addSql('ALTER TABLE chill_main_address ADD createdAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ADD updatedAt TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ADD createdBy_id INT DEFAULT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ADD updatedBy_id INT DEFAULT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER street TYPE TEXT');
+ $this->addSql('UPDATE chill_main_address SET street=\'\' WHERE street IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER street SET DEFAULT \'\'');
+ $this->addSql('ALTER TABLE chill_main_address ALTER streetnumber TYPE TEXT');
+ $this->addSql('UPDATE chill_main_address SET streetnumber=\'\' WHERE streetnumber IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER streetnumber SET DEFAULT \'\'');
+ $this->addSql('ALTER TABLE chill_main_address ALTER floor SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address SET floor=\'\' WHERE floor IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER floor SET NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER corridor SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address SET corridor=\'\' WHERE corridor IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER corridor SET NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER steps SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address SET steps=\'\' WHERE steps IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER steps SET NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER buildingname TYPE TEXT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER buildingname SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address SET buildingname=\'\' WHERE buildingname IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER buildingname SET NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER flat SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address SET flat=\'\' WHERE flat IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER flat SET NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER distribution TYPE TEXT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER distribution SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address SET distribution=\'\' WHERE distribution IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER distribution SET NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER extra TYPE TEXT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER extra SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address SET extra=\'\' WHERE extra IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER extra SET NOT NULL');
+ $this->addSql('UPDATE chill_main_address SET confidential=FALSE WHERE confidential IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER confidential SET NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER refstatuslastupdate TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
+ $this->addSql('COMMENT ON COLUMN chill_main_address.point IS \'(DC2Type:point)\'');
+ $this->addSql('COMMENT ON COLUMN chill_main_address.createdAt IS \'(DC2Type:datetime_immutable)\'');
+ $this->addSql('COMMENT ON COLUMN chill_main_address.updatedAt IS \'(DC2Type:datetime_immutable)\'');
+ $this->addSql('COMMENT ON COLUMN chill_main_address.refStatusLastUpdate IS \'(DC2Type:datetime_immutable)\'');
+ $this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT FK_165051F63174800F FOREIGN KEY (createdBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+ $this->addSql('ALTER TABLE chill_main_address ADD CONSTRAINT FK_165051F665FF1AEC FOREIGN KEY (updatedBy_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
+ $this->addSql('CREATE INDEX IDX_165051F63174800F ON chill_main_address (createdBy_id)');
+ $this->addSql('CREATE INDEX IDX_165051F665FF1AEC ON chill_main_address (updatedBy_id)');
+ $this->addSql('COMMENT ON COLUMN chill_main_address_reference.point IS \'(DC2Type:point)\'');
+
+ }
+
+ public function down(Schema $schema): void
+ {
+ $this->throwIrreversibleMigrationException('down method is not double-checked');
+
+ $this->addSql('ALTER TABLE chill_main_address DROP CONSTRAINT FK_165051F63174800F');
+ $this->addSql('ALTER TABLE chill_main_address DROP CONSTRAINT FK_165051F665FF1AEC');
+ $this->addSql('DROP INDEX IDX_165051F63174800F');
+ $this->addSql('DROP INDEX IDX_165051F665FF1AEC');
+ $this->addSql('ALTER TABLE chill_main_address ADD customs JSONB DEFAULT \'[]\'');
+ $this->addSql('ALTER TABLE chill_main_address DROP createdAt');
+ $this->addSql('ALTER TABLE chill_main_address DROP updatedAt');
+ $this->addSql('ALTER TABLE chill_main_address DROP createdBy_id');
+ $this->addSql('ALTER TABLE chill_main_address DROP updatedBy_id');
+ $this->addSql('ALTER TABLE chill_main_address ALTER buildingName TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address ALTER buildingName DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER buildingName DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER confidential SET DEFAULT false');
+ $this->addSql('ALTER TABLE chill_main_address ALTER confidential DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER corridor DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER corridor DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER distribution TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address ALTER distribution DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER distribution DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER extra TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address ALTER extra DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER extra DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER flat DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER flat DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER floor DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER floor DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER isNoAddress SET DEFAULT false');
+ $this->addSql('ALTER TABLE chill_main_address ALTER point TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address ALTER refStatusLastUpdate TYPE TIMESTAMP(0) WITHOUT TIME ZONE');
+ $this->addSql('ALTER TABLE chill_main_address ALTER steps DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER steps DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address ALTER street TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address ALTER street DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address ALTER streetNumber TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address ALTER streetNumber DROP DEFAULT');
+ $this->addSql('COMMENT ON COLUMN chill_main_address.refstatuslastupdate IS NULL');
+ }
+}
diff --git a/src/Bundle/ChillMainBundle/migrations/Version20230306151218.php b/src/Bundle/ChillMainBundle/migrations/Version20230306151218.php
new file mode 100644
index 000000000..d3d467bea
--- /dev/null
+++ b/src/Bundle/ChillMainBundle/migrations/Version20230306151218.php
@@ -0,0 +1,58 @@
+addSql('ALTER TABLE chill_main_address_reference ALTER refid TYPE TEXT');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER refid SET DEFAULT \'\'');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER street TYPE TEXT');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER street SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address_reference SET street = \'\' WHERE street IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER street SET NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER streetnumber TYPE TEXT');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER streetnumber SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address_reference SET streetnumber = \'\' WHERE streetnumber IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER streetnumber SET NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalitycode TYPE TEXT');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalitycode SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address_reference SET municipalitycode = \'\' WHERE municipalitycode IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalitycode SET NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER source TYPE TEXT');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER source SET DEFAULT \'\'');
+ $this->addSql('UPDATE chill_main_address_reference SET source = \'\' WHERE source IS NULL');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER source SET NOT NULL');
+ }
+
+ public function down(Schema $schema): void
+ {
+ $this->throwIrreversibleMigrationException('not double-checked');
+
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalityCode TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalityCode DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER municipalityCode DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER refId TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER refId DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER source TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER source DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER source DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER street TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER street DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER street DROP NOT NULL');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER streetNumber TYPE VARCHAR(255)');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER streetNumber DROP DEFAULT');
+ $this->addSql('ALTER TABLE chill_main_address_reference ALTER streetNumber DROP NOT NULL');
+ }
+}