mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-19 08:44:24 +00:00
43 lines
1.1 KiB
PHP
43 lines
1.1 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);
|
|
|
|
/*
|
|
* 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\CalendarBundle\Security\Voter;
|
|
|
|
use Chill\CalendarBundle\Entity\Invite;
|
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
|
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
|
|
|
class InviteVoter extends Voter
|
|
{
|
|
public const ANSWER = 'CHILL_CALENDAR_INVITE_ANSWER';
|
|
|
|
protected function supports($attribute, $subject): bool
|
|
{
|
|
return $subject instanceof Invite && self::ANSWER === $attribute;
|
|
}
|
|
|
|
/**
|
|
* @param string $attribute
|
|
* @param Invite $subject
|
|
*/
|
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
|
{
|
|
return $token->getUser() === $subject->getUser();
|
|
}
|
|
}
|