Ajout de permissions sur le module Ticket

This commit is contained in:
2026-03-23 11:44:30 +00:00
parent 63fc600be6
commit eff0f6bcda
35 changed files with 486 additions and 68 deletions

View File

@@ -133,6 +133,9 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, length: 5, nullable: false, options: ['default' => 'fr'])]
private string $locale = 'fr';
#[ORM\ManyToMany(targetEntity: UserGroup::class, mappedBy: 'users')]
private Collection&Selectable $groupsAsMember;
/**
* User constructor.
*/
@@ -141,6 +144,7 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
$this->groupCenters = new ArrayCollection();
$this->scopeHistories = new ArrayCollection();
$this->jobHistories = new ArrayCollection();
$this->groupsAsMember = new ArrayCollection();
}
public function __toString(): string
@@ -170,6 +174,32 @@ class User implements UserInterface, \Stringable, PasswordAuthenticatedUserInter
return $this->absenceEnd;
}
public function addGroupAsMember(UserGroup $userGroup): self
{
if (!$this->groupsAsMember->contains($userGroup)) {
$this->groupsAsMember->add($userGroup);
}
return $this;
}
public function removeGroupAsMember(UserGroup $userGroup): self
{
if ($this->groupsAsMember->contains($userGroup)) {
$this->groupsAsMember->removeElement($userGroup);
}
return $this;
}
/**
* @return Selectable&Collection<int, UserGroup>
*/
public function getGroupsAsMember(): Collection&Selectable
{
return $this->groupsAsMember;
}
/**
* Get attributes.
*

View File

@@ -54,7 +54,7 @@ class UserGroup
/**
* @var Collection<int, User>&Selectable<int, User>
*/
#[ORM\ManyToMany(targetEntity: User::class)]
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'groupsAsMember')]
#[ORM\JoinTable(name: 'chill_main_user_group_user')]
private Collection&Selectable $users;
@@ -129,6 +129,7 @@ class UserGroup
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->addGroupAsMember($this);
}
return $this;
@@ -138,6 +139,7 @@ class UserGroup
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
$user->removeGroupAsMember($this);
}
return $this;