Enums are recommended if you need to manipulate some state of entity. All enum objects must implement EnumInterface and use BaseEnumTrait. Then you should override one constant:
public const Default = '';
Here is the example of implementation for user state:
App\Model\Enum\UserState
:
<?php
declare(strict_types=1);
namespace App\Model\Enum;
use AnzuSystems\Contracts\Model\Enum\BaseEnumTrait;
use AnzuSystems\Contracts\Model\Enum\EnumInterface;
enum UserState: string implements EnumInterface
{
use BaseEnumTrait;
case Active = 'active';
case GdprDeleted = 'gdpr_deleted';
public const Default = self::Active;
}
App\Entity\User
:
<?php
declare(strict_types=1);
namespace App\Entity;
use AnzuSystems\Contracts\Entity\AnzuUser;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity]
class User extends AnzuUser
{
#[ORM\Column(enumType: UserState::class)]
private UserState $state;
}