mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-03 15:36:14 +00:00
fix deprecations: implement abstract function for reportVoter
This commit is contained in:
parent
1b4bb4f7bc
commit
eeff93c88a
@ -19,9 +19,14 @@
|
|||||||
|
|
||||||
namespace Chill\ReportBundle\Security\Authorization;
|
namespace Chill\ReportBundle\Security\Authorization;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
|
|
||||||
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
|
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
|
||||||
|
use Chill\ReportBundle\Entity\Report;
|
||||||
|
use Chill\MainBundle\Entity\User;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -40,31 +45,34 @@ class ReportVoter extends AbstractChillVoter implements ProvideRoleHierarchyInte
|
|||||||
*/
|
*/
|
||||||
protected $helper;
|
protected $helper;
|
||||||
|
|
||||||
|
|
||||||
public function __construct(AuthorizationHelper $helper)
|
public function __construct(AuthorizationHelper $helper)
|
||||||
{
|
{
|
||||||
$this->helper = $helper;
|
$this->helper = $helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getSupportedAttributes()
|
|
||||||
{
|
|
||||||
return array(self::CREATE, self::SEE, self::UPDATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getSupportedClasses()
|
protected function supports($attribute, $subject)
|
||||||
{
|
{
|
||||||
return array('Chill\ReportBundle\Entity\Report');
|
if ($subject instanceof Report) {
|
||||||
}
|
return \in_array($attribute, [
|
||||||
|
self::CREATE, self::UPDATE, self::SEE
|
||||||
protected function isGranted($attribute, $report, $user = null)
|
]);
|
||||||
{
|
} else {
|
||||||
if (! $user instanceof \Chill\MainBundle\Entity\User){
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->helper->userHasAccess($user, $report, $attribute);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||||
|
{
|
||||||
|
if (!$token->getUser() instanceof User) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $this->helper->userHasAccess($token->getUser(), $subject, $attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getRoles()
|
public function getRoles()
|
||||||
{
|
{
|
||||||
return $this->getSupportedAttributes();
|
return $this->getSupportedAttributes();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user