Skip to content

Commit

Permalink
#469 enum p16
Browse files Browse the repository at this point in the history
  • Loading branch information
eventhorizonpl committed Jan 27, 2022
1 parent 94b898b commit c7ab919
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/Entity/AccountOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ class AccountOperation
private int $smsNotifications;

#[Assert\Choice(callback: 'getTypeValidationChoices', groups: ['system'])]
#[Assert\Length(groups: ['system'], max: 8)]
#[Assert\NotBlank(groups: ['system'])]
#[Assert\Type('string', groups: ['system'])]
#[ORM\Column(length: 8, type: Types::STRING)]
#[Assert\Type(AccountOperationTypeEnum::class, groups: ['system'])]
#[ORM\Column(enumType: AccountOperationTypeEnum::class, length: 8, type: Types::STRING)]
private AccountOperationTypeEnum $type;

public function __construct()
Expand Down Expand Up @@ -144,7 +143,10 @@ public static function getTypeFormChoices(): array

public static function getTypeValidationChoices(): array
{
return array_keys(self::getTypeFormChoices());
return [
AccountOperationTypeEnum::DEPOSIT,
AccountOperationTypeEnum::WITHDRAW,
];
}

public function setType(AccountOperationTypeEnum $type): self
Expand Down
11 changes: 7 additions & 4 deletions src/Entity/Testimonial.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ class Testimonial
private ?string $signature;

#[Assert\Choice(callback: 'getStatusValidationChoices', groups: ['system'])]
#[Assert\Length(groups: ['system'], max: 8)]
#[Assert\NotBlank(groups: ['system'])]
#[Assert\Type('string', groups: ['system'])]
#[ORM\Column(length: 8, type: Types::STRING)]
#[Assert\Type(TestimonialStatusEnum::class, groups: ['system'])]
#[ORM\Column(enumType: TestimonialStatusEnum::class, length: 8, type: Types::STRING)]
private TestimonialStatusEnum $status;

public function __construct()
Expand Down Expand Up @@ -101,7 +100,11 @@ public static function getStatusFormChoices(): array

public static function getStatusValidationChoices(): array
{
return array_keys(self::getStatusFormChoices());
return [
TestimonialStatusEnum::ACCEPTED,
TestimonialStatusEnum::NEW,
TestimonialStatusEnum::REJECTED,
];
}

public function setStatus(TestimonialStatusEnum $status): self
Expand Down

0 comments on commit c7ab919

Please sign in to comment.