Implement StoredObjectVoterInterface

An interface was created to be implemented by Stored Doc voters\
these will automatically be tagged and injected into DocStoreVoter.
This commit is contained in:
Julie Lenaerts 2024-06-19 10:21:24 +02:00
parent 062afd6695
commit f75c7a0232

View File

@ -19,11 +19,12 @@ use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use ChillDocStoreBundle\Security\Authorization\StoredObjectVoterInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security;
class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface, StoredObjectVoterInterface
{
final public const CREATE = 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE';
@ -70,12 +71,12 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov
return [];
}
protected function supports($attribute, $subject): bool
public function supports($attribute, $subject): bool
{
return $this->voterHelper->supports($attribute, $subject);
}
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
public function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
{
if (!$token->getUser() instanceof User) {
return false;