<?php
namespace App\Security\Voter;
use App\Entity\Document;
use Symfony\Component\Security\Core\User\UserInterface;
class DocumentVoter extends AbstractDeepVoter
{
public static $listAttribute = 'list_documents';
public static $createAttribute = 'create_document';
protected function listAttribute(): string
{
return self::$listAttribute;
}
protected function createAttribute(): string
{
return self::$createAttribute;
}
protected function isSupportedSubject(object $subject): bool
{
return $subject instanceof Document;
}
protected function canList(UserInterface $user): bool
{
return true;
}
protected function canCreate(UserInterface $user): bool
{
return $user->isAnAdmin();
}
protected function canRead(UserInterface $user): bool
{
return true;
}
protected function canUpdate(UserInterface $user): bool
{
return $user->isAnAdmin();
}
protected function canDelete(UserInterface $user): bool
{
return $user->isAnAdmin();
}
}