<?phpnamespace App\Entity;use App\Entity\Interface\NotificationInterface;use App\Entity\Traits\TimestampTrait;use App\Repository\RoleManagementRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;#[ORM\Entity(repositoryClass: RoleManagementRepository::class)]#[UniqueEntity(fields: ['roleName'])]class RoleManagement implements NotificationInterface{ use TimestampTrait; public const SUPER_ADMIN = 'Super Admin'; public const ROLE_CLIENT = 'Client'; public const REGULAR_ADMIN = 'Admin'; public const STANDARD_USER = 'User'; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] private $id; #[ORM\Column(type: 'string', length: 255)] private $roleName; #[ORM\Column(type: 'json', nullable: true)] private $routePermissions = []; #[ORM\ManyToMany(targetEntity: NotificationProfile::class, mappedBy: 'roleToSend')] private $notificationProfiles; #[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'userRole')] private $users; public function __construct() { $this->notificationProfiles = new ArrayCollection(); $this->users = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getRoleName(): ?string { return $this->roleName; } public function setRoleName(string $roleName): self { $this->roleName = $roleName; return $this; } public function getRoutePermissions(): ?array { return $this->routePermissions; } public function setRoutePermissions(?array $routePermissions): self { $this->routePermissions = $routePermissions; return $this; } /** * @return Collection<int, NotificationProfile> */ public function getNotificationProfiles(): Collection { return $this->notificationProfiles; } public function addNotificationProfile(NotificationProfile $notificationProfile): self { if (!$this->notificationProfiles->contains($notificationProfile)) { $this->notificationProfiles[] = $notificationProfile; $notificationProfile->addRoleToSend($this); } return $this; } public function removeNotificationProfile(NotificationProfile $notificationProfile): self { if ($this->notificationProfiles->removeElement($notificationProfile)) { $notificationProfile->removeRoleToSend($this); } return $this; } /** * @return Collection<int, User> */ public function getUsers(): Collection { return $this->users; } public function addUser(User $user): self { if (!$this->users->contains($user)) { $this->users[] = $user; $user->addUserRole($this); } return $this; } public function removeUser(User $user): self { if ($this->users->removeElement($user)) { $user->removeUserRole($this); } return $this; }}