mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-01 19:09:45 +00:00
Partage d'export enregistré et génération asynchrone des exports
This commit is contained in:
@@ -11,12 +11,21 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
|
||||
class ChillExportVoter extends Voter
|
||||
class ChillExportVoter extends Voter implements ProvideRoleHierarchyInterface
|
||||
{
|
||||
final public const EXPORT = 'chill_export';
|
||||
/**
|
||||
* Role which give access to the creation of new export from the export itself.
|
||||
*/
|
||||
final public const COMPOSE_EXPORT = 'CHILL_MAIN_COMPOSE_EXPORT';
|
||||
|
||||
/**
|
||||
* Role which give access to the execution and edition to the saved exports, but not for creating new ones.
|
||||
*/
|
||||
final public const GENERATE_SAVED_EXPORT = 'CHILL_MAIN_GENERATE_SAVED_EXPORT';
|
||||
|
||||
private readonly VoterHelperInterface $helper;
|
||||
|
||||
@@ -24,7 +33,7 @@ class ChillExportVoter extends Voter
|
||||
{
|
||||
$this->helper = $voterHelperFactory
|
||||
->generate(self::class)
|
||||
->addCheckFor(null, [self::EXPORT])
|
||||
->addCheckFor(null, [self::COMPOSE_EXPORT, self::GENERATE_SAVED_EXPORT])
|
||||
->build();
|
||||
}
|
||||
|
||||
@@ -37,4 +46,21 @@ class ChillExportVoter extends Voter
|
||||
{
|
||||
return $this->helper->voteOnAttribute($attribute, $subject, $token);
|
||||
}
|
||||
|
||||
public function getRolesWithHierarchy(): array
|
||||
{
|
||||
return ['export.role.export_role' => [
|
||||
self::COMPOSE_EXPORT, self::GENERATE_SAVED_EXPORT,
|
||||
]];
|
||||
}
|
||||
|
||||
public function getRoles(): array
|
||||
{
|
||||
return [self::COMPOSE_EXPORT, self::GENERATE_SAVED_EXPORT];
|
||||
}
|
||||
|
||||
public function getRolesWithoutScope(): array
|
||||
{
|
||||
return $this->getRoles();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user