mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
Now, the bundle dispatch an event `chill_task.vote` to override the authorization on voting on a task. If a subscriber or listener emits a vote on the event, this vote override the logic defined for the default task.
90 lines
1.5 KiB
PHP
90 lines
1.5 KiB
PHP
<?php
|
|
/*
|
|
*
|
|
*/
|
|
namespace Chill\TaskBundle\Security\Authorization;
|
|
|
|
use Symfony\Component\EventDispatcher\Event;
|
|
use Chill\TaskBundle\Entity\AbstractTask;
|
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
|
|
|
/**
|
|
*
|
|
*
|
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
*/
|
|
class AuthorizationEvent extends Event
|
|
{
|
|
/**
|
|
* @var AbstractTask
|
|
*/
|
|
protected $task;
|
|
|
|
/**
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $attribute;
|
|
|
|
/**
|
|
*
|
|
* @var TokenInterface
|
|
*/
|
|
protected $token;
|
|
|
|
/**
|
|
*
|
|
* @var bool
|
|
*/
|
|
protected $vote;
|
|
|
|
const VOTE = 'chill_task.vote';
|
|
|
|
public function __construct(
|
|
AbstractTask $task,
|
|
$attribute,
|
|
TokenInterface $token
|
|
) {
|
|
$this->task = $task;
|
|
$this->attribute = $attribute;
|
|
$this->token = $token;
|
|
}
|
|
|
|
public function getTask(): AbstractTask
|
|
{
|
|
return $this->task;
|
|
}
|
|
|
|
public function getAttribute()
|
|
{
|
|
return $this->attribute;
|
|
}
|
|
|
|
public function getToken(): TokenInterface
|
|
{
|
|
return $this->token;
|
|
}
|
|
|
|
public function getVote()
|
|
{
|
|
return $this->vote;
|
|
}
|
|
|
|
public function setVote($vote)
|
|
{
|
|
$this->vote = $vote;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function hasVote()
|
|
{
|
|
return $this->vote !== NULL;
|
|
}
|
|
|
|
public function removeVote()
|
|
{
|
|
$this->vote = NULL;
|
|
}
|
|
}
|