Fix: authorization helper won't send a list of center if an admin is authenticated

This commit is contained in:
Julien Fastré 2023-04-24 15:50:27 +02:00
parent 0c5a06c678
commit 9918cf2d58
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB
3 changed files with 17 additions and 36 deletions

View File

@ -2631,11 +2631,6 @@ parameters:
count: 2
path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
-
message: "#^Call to method getRoleScopes\\(\\) on an unknown class Chill\\\\MainBundle\\\\Entity\\\\PermissionGroup\\.$#"
count: 1
path: src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
-
message: "#^Empty array passed to foreach\\.$#"
count: 1

View File

@ -31,7 +31,7 @@ class GroupCenter
* )
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private $center;
private ?Center $center = null;
/**
* @var int
@ -40,83 +40,64 @@ class GroupCenter
* @ORM\Column(name="id", type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
private ?int $id = null;
/**
* @var PermissionsGroup
*
* @ORM\ManyToOne(
* targetEntity="Chill\MainBundle\Entity\PermissionsGroup",
* inversedBy="groupCenters")
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
private $permissionsGroup;
private ?PermissionsGroup $permissionsGroup = null;
/**
* @var Collection
*
* @ORM\ManyToMany(
* targetEntity="Chill\MainBundle\Entity\User",
* mappedBy="groupCenters"
* )
* @var Collection<User::class>
*/
private $users;
private Collection $users;
/**
* GroupCenter constructor.
*/
public function __construct()
{
$this->permissionsGroup = new ArrayCollection();
$this->users = new ArrayCollection();
}
/**
* @return Center
*/
public function getCenter()
public function getCenter(): ?Center
{
return $this->center;
}
/**
* @return int
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
/**
* @return PermissionGroup
*/
public function getPermissionsGroup()
public function getPermissionsGroup(): ?PermissionsGroup
{
return $this->permissionsGroup;
}
/**
* @return ArrayCollection|Collection
* @return Collection<User::class>
*/
public function getUsers()
public function getUsers(): Collection
{
return $this->users;
}
/**
* @return \Chill\MainBundle\Entity\GroupCenter
*/
public function setCenter(Center $center)
public function setCenter(Center $center): self
{
$this->center = $center;
return $this;
}
/**
* @return \Chill\MainBundle\Entity\GroupCenter
*/
public function setPermissionsGroup(PermissionsGroup $permissionsGroup)
public function setPermissionsGroup(PermissionsGroup $permissionsGroup): self
{
$this->permissionsGroup = $permissionsGroup;

View File

@ -120,6 +120,11 @@ class AuthorizationHelper implements AuthorizationHelperInterface
if ($role instanceof Role) {
$role = $role->getRole();
}
if (!$user instanceof User) {
return [];
}
/** @var array<string, Center> $centers */
$centers = [];