Skip to content

Commit

Permalink
wip enum status signalement #3572
Browse files Browse the repository at this point in the history
  • Loading branch information
emilschn committed Feb 3, 2025
1 parent 439c9c2 commit b739867
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
26 changes: 26 additions & 0 deletions migrations/Version20250203165635.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

final class Version20250203165635 extends AbstractMigration
{
public function getDescription(): string
{
return 'change signalement statut to enum';
}

public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE signalement CHANGE statut statut VARCHAR(255) NOT NULL');
}

public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE signalement CHANGE statut statut INT NOT NULL');
}
}
14 changes: 7 additions & 7 deletions src/Entity/Enum/SignalementStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

use App\Entity\Behaviour\EnumTrait;

enum SignalementStatus: int
enum SignalementStatus: string
{
use EnumTrait;

case NEED_VALIDATION = 1;
case ACTIVE = 2;
case NEED_PARTNER_RESPONSE = 3;
case CLOSED = 6;
case ARCHIVED = 7;
case REFUSED = 8;
case NEED_VALIDATION = 'NEED_VALIDATION';
case ACTIVE = 'ACTIVE';
case NEED_PARTNER_RESPONSE = 'NEED_PARTNER_RESPONSE';
case CLOSED = 'CLOSED';
case ARCHIVED = 'ARCHIVED';
case REFUSED = 'REFUSED';

public function mapAffectationStatus(): int
{
Expand Down
11 changes: 6 additions & 5 deletions src/Entity/Signalement.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Entity\Enum\ProfileDeclarant;
use App\Entity\Enum\ProprioType;
use App\Entity\Enum\Qualification;
use App\Entity\Enum\SignalementStatus;
use App\Entity\Model\InformationComplementaire;
use App\Entity\Model\InformationProcedure;
use App\Entity\Model\SituationFoyer;
Expand Down Expand Up @@ -215,8 +216,8 @@ class Signalement implements EntityHistoryInterface, EntityHistoryCollectionInte
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $modifiedAt = null;

#[ORM\Column(type: 'integer')]
private ?int $statut = null;
#[ORM\Column(type: 'string', enumType: SignalementStatus::class)]
private ?SignalementStatus $statut = null;

#[ORM\Column(type: 'string', length: 100)]
private ?string $reference = null;
Expand Down Expand Up @@ -444,7 +445,7 @@ public function __construct()
$this->criteres = new ArrayCollection();
$this->criticites = new ArrayCollection();
$this->createdAt = new \DateTimeImmutable();
$this->statut = self::STATUS_NEED_VALIDATION;
$this->statut = SignalementStatus::NEED_VALIDATION;
$this->uuid = Uuid::v4();
$this->codeSuivi = Uuid::v4();
$this->suivis = new ArrayCollection();
Expand Down Expand Up @@ -1161,12 +1162,12 @@ public function setCreatedBy(?User $createdBy): self
return $this;
}

public function getStatut(): ?int
public function getStatut(): ?SignalementStatus
{
return $this->statut;
}

public function setStatut(int $statut): self
public function setStatut(SignalementStatus $statut): self
{
$this->statut = $statut;

Expand Down

0 comments on commit b739867

Please sign in to comment.