mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 03:23:48 +00:00
Feature: [person][creation] api for listing availables centers for person creation
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Security;
|
||||
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelperForCurrentUserInterface;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
|
||||
class AuthorizedCenterOnPersonCreation implements AuthorizedCenterOnPersonCreationInterface
|
||||
{
|
||||
private AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser;
|
||||
|
||||
private bool $showCenters;
|
||||
|
||||
public function __construct(AuthorizationHelperForCurrentUserInterface $authorizationHelperForCurrentUser, ParameterBagInterface $parameterBag)
|
||||
{
|
||||
$this->authorizationHelperForCurrentUser = $authorizationHelperForCurrentUser;
|
||||
$this->showCenter = $parameterBag->get('chill_main')['acl']['form_show_centers'];
|
||||
}
|
||||
|
||||
public function getCenters(): array
|
||||
{
|
||||
if (!$this->showCenter) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->authorizationHelperForCurrentUser->getReachableCenters(PersonVoter::CREATE);
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Security;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
|
||||
interface AuthorizedCenterOnPersonCreationInterface
|
||||
{
|
||||
/**
|
||||
* @return array|Center[]
|
||||
*/
|
||||
public function getCenters(): array;
|
||||
}
|
Reference in New Issue
Block a user