mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-17 07:44:24 +00:00
52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\TaskBundle\Workflow\Event;
|
|
|
|
use Chill\TaskBundle\Security\Authorization\TaskVoter;
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
|
use Symfony\Component\Workflow\Event\GuardEvent;
|
|
|
|
class DefaultTaskGuardEvent implements EventSubscriberInterface
|
|
{
|
|
/**
|
|
* @var AuthorizationCheckerInterface
|
|
*/
|
|
protected $authorizationChecker;
|
|
|
|
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
|
|
{
|
|
$this->authorizationChecker = $authorizationChecker;
|
|
}
|
|
|
|
public function checkACL(GuardEvent $event)
|
|
{
|
|
if (
|
|
false === $this->authorizationChecker->isGranted(
|
|
TaskVoter::UPDATE,
|
|
$event->getSubject()
|
|
)
|
|
) {
|
|
$event->setBlocked(true);
|
|
}
|
|
}
|
|
|
|
public static function getSubscribedEvents(): array
|
|
{
|
|
return [
|
|
'workflow.task_default.guard' => [
|
|
'checkACL',
|
|
],
|
|
];
|
|
}
|
|
}
|