wip: use GenderIconEnum to allow user to select bootstrap icon

This commit is contained in:
2024-09-26 15:45:44 +02:00
parent 67a6eb17db
commit 567c01f395
6 changed files with 30 additions and 13 deletions

View File

@@ -30,8 +30,8 @@ class Gender
private GenderEnum $genderTranslation;
#[Serializer\Groups(['read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 255)]
private string $icon = '';
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, enumType: GenderIconEnum::class)]
private GenderIconEnum $icon;
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::FLOAT, name: 'ordering', nullable: true, options: ['default' => '0.0'])]
private float $order = 0;
@@ -71,12 +71,12 @@ class Gender
$this->$genderTranslation = $genderTranslation;
}
public function getIcon(): string
public function getIcon(): GenderIconEnum
{
return $this->icon;
}
public function setIcon(string $icon): void
public function setIcon(GenderIconEnum $icon): void
{
$this->icon = $icon;
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Chill\MainBundle\Entity;
enum GenderIconEnum: string
{
case MALE = 'bi bi-gender-male';
case FEMALE = 'bi bi-gender-female';
case NEUTRAL = 'bi bi-gender-neuter';
case AMBIGUOUS = 'bi bi-gender-ambiguous';
case TRANS = 'bi bi-gender-trans';
}