Skip to content

Commit

Permalink
Finish
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca committed Dec 3, 2024
1 parent 43e3247 commit f03e819
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Application\QueryInterface;
use App\Application\Regulation\Query\Location\GetNamedStreetGeometryQuery;
use App\Domain\Geography\Coordinates;
use App\Domain\Regulation\Enum\DirectionEnum;
use App\Domain\Regulation\Location\Location;
use App\Domain\Regulation\Location\NamedStreet;

Expand All @@ -27,7 +28,7 @@ final class SaveNamedStreetCommand implements RoadCommandInterface
private ?bool $isEntireStreetFormValue = null;
public ?string $geometry = null;
public ?Location $location = null;
public ?string $direction = null;
public string $direction = DirectionEnum::BOTH->value;

public function __construct(
public readonly ?NamedStreet $namedStreet = null,
Expand All @@ -43,7 +44,7 @@ public function __construct(
$this->toRoadName = $namedStreet?->getToRoadName();
$this->isEntireStreetFormValue = $namedStreet ? $this->computeIsEntireStreetFormValue() : null;
$this->roadType = $namedStreet?->getLocation()?->getRoadType();
$this->direction = $namedStreet?->getDirection();
$this->direction = $namedStreet?->getDirection() ?? DirectionEnum::BOTH->value;
}

public function clean(): void
Expand Down
1 change: 1 addition & 0 deletions src/Infrastructure/Form/Regulation/NamedStreetFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event): void {
$data = $event->getData();
$data['roadType'] = $event->getForm()->getParent()->get('roadType')->getData();
$data['direction'] = $data['direction'] ?? DirectionEnum::BOTH->value; // Prevent null if entire street is checked
$event->setData($data);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use App\Domain\Geography\Coordinates;
use App\Domain\Geography\GeoJSON;
use App\Domain\Regulation\Enum\DirectionEnum;
use App\Domain\Regulation\Enum\RoadTypeEnum;
use App\Domain\Regulation\Location\Location;
use App\Domain\Regulation\Location\NamedStreet;
Expand Down Expand Up @@ -44,6 +45,7 @@ public function load(ObjectManager $manager): void
$namedStreetTypicalMeasureLocation1 = new NamedStreet(
uuid: '047d007c-f468-4f80-9f8c-11cd19cfe0c1',
location: $typicalMeasureLocation1,
direction: DirectionEnum::A_TO_B->value,
cityCode: '44195',
cityLabel: 'Savenay (44260)',
roadName: 'Route du Grand Brossais',
Expand All @@ -61,6 +63,7 @@ public function load(ObjectManager $manager): void
$namedStreetTypicalMeasureLocation2 = new NamedStreet(
uuid: 'b291d4ef-9a78-43c4-9f4f-babc256ac320',
location: $typicalMeasureLocation2,
direction: DirectionEnum::BOTH->value,
cityCode: '44195',
cityLabel: 'Savenay (44260)',
roadName: 'Rue Victor Hugo',
Expand All @@ -78,6 +81,7 @@ public function load(ObjectManager $manager): void
$namedStreetTypicalMeasureLocation3 = new NamedStreet(
uuid: 'f8f38bf6-6dec-4a0a-aa23-0d934cc49e55',
location: $typicalMeasureLocation3,
direction: DirectionEnum::BOTH->value,
cityCode: '82121',
cityLabel: 'Montauban (82000)',
roadName: 'Avenue de Fonneuve',
Expand Down Expand Up @@ -115,6 +119,7 @@ public function load(ObjectManager $manager): void
$namedStreetTypicalMeasureToRemoveLocation1 = new NamedStreet(
uuid: 'b640220b-a80b-45b7-915c-b1fc878ada9a',
location: $typicalMeasureToRemoveLocation1,
direction: DirectionEnum::BOTH->value,
cityCode: '44195',
cityLabel: 'Savenay (44260)',
roadName: 'Route du Grand Brossais',
Expand All @@ -135,6 +140,7 @@ public function load(ObjectManager $manager): void
$namedStreetPublishedLocation1 = new NamedStreet(
uuid: 'e998d4bc-2e4a-4686-9105-e06869ddb24b',
location: $publishedLocation1,
direction: DirectionEnum::BOTH->value,
cityCode: '82121',
cityLabel: 'Montauban (82000)',
roadName: 'Avenue de Fonneuve',
Expand All @@ -152,6 +158,7 @@ public function load(ObjectManager $manager): void
$namedStreetPublishedLocation2 = new NamedStreet(
uuid: '1578630f-06d7-457a-bfde-8447be156107',
location: $publishedLocation2,
direction: DirectionEnum::BOTH->value,
cityCode: '82121',
cityLabel: 'Montauban (82000)',
roadName: "Rue de l'Hôtel de Ville",
Expand All @@ -169,6 +176,7 @@ public function load(ObjectManager $manager): void
$namedStreetPublishedLocation3 = new NamedStreet(
uuid: 'c477f85d-0827-454e-932d-d0e1ce8ebe0c',
location: $publishedLocation3,
direction: DirectionEnum::BOTH->value,
cityCode: '82121',
cityLabel: 'Montauban (82000)',
roadName: 'Rue Gamot',
Expand Down Expand Up @@ -204,6 +212,7 @@ public function load(ObjectManager $manager): void
$namedStreetPermanentRegulationOrderLocation = new NamedStreet(
uuid: '5a2f6655-5903-4b57-97be-fe6906f8aa42',
location: $permanentRegulationOrderLocation,
direction: DirectionEnum::BOTH->value,
cityCode: '75118',
cityLabel: 'Paris 18e Arrondissement (75018)',
roadName: 'Rue du Simplon',
Expand All @@ -221,6 +230,7 @@ public function load(ObjectManager $manager): void
$namedStreetFullCityLocation = new NamedStreet(
uuid: 'be75b5f0-e1e3-4162-b1af-3dff1946ca36',
location: $fullCityLocation,
direction: DirectionEnum::BOTH->value,
cityCode: '75118',
cityLabel: 'Paris 18e Arrondissement (75018)',
roadName: null,
Expand All @@ -245,6 +255,7 @@ public function load(ObjectManager $manager): void
$namedStreetCifsLocation = new NamedStreet(
uuid: '72b70089-04ea-4ba0-8d9e-61ca86fc2413',
location: $cifsLocation,
direction: DirectionEnum::BOTH->value,
cityCode: '82121',
cityLabel: 'Montauban (82000)',
roadName: 'Rue de la République',
Expand Down

0 comments on commit f03e819

Please sign in to comment.