88 lines
1.5 KiB
PHP

<?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\TaskBundle\Security\Authorization;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
class AuthorizationEvent extends Event
{
public const VOTE = 'chill_task.vote';
/**
* @var string
*/
protected $attribute;
/**
* @var \Chill\PersonBundle\Entity\Person|Chill\TaskBundle\Entity\AbstractTask|null
*/
protected $subject;
/**
* @var TokenInterface
*/
protected $token;
/**
* @var bool
*/
protected $vote;
public function __construct(
$subject,
$attribute,
TokenInterface $token
) {
$this->subject = $subject;
$this->attribute = $attribute;
$this->token = $token;
}
public function getAttribute()
{
return $this->attribute;
}
public function getSubject()
{
return $this->subject;
}
public function getToken(): TokenInterface
{
return $this->token;
}
public function getVote()
{
return $this->vote;
}
public function hasVote()
{
return null !== $this->vote;
}
public function removeVote()
{
$this->vote = null;
}
public function setVote($vote)
{
$this->vote = $vote;
return $this;
}
}