cs: Fix code style (safe rules only).

This commit is contained in:
Pol Dellaiera
2021-11-23 14:06:38 +01:00
parent 149d7ce991
commit 8f96a1121d
1223 changed files with 65199 additions and 64625 deletions

View File

@@ -1,29 +1,42 @@
<?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.
*/
namespace Chill\DocStoreBundle\Security\Authorization;
use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
use Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface;
use Chill\MainBundle\Security\Authorization\VoterHelperInterface;
use Chill\MainBundle\Security\ProvideRoleHierarchyInterface;
use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\PersonBundle\Entity\Person;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Security;
class PersonDocumentVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
{
const CREATE = 'CHILL_PERSON_DOCUMENT_CREATE';
const SEE = 'CHILL_PERSON_DOCUMENT_SEE';
const SEE_DETAILS = 'CHILL_PERSON_DOCUMENT_SEE_DETAILS';
const UPDATE = 'CHILL_PERSON_DOCUMENT_UPDATE';
const DELETE = 'CHILL_PERSON_DOCUMENT_DELETE';
public const CREATE = 'CHILL_PERSON_DOCUMENT_CREATE';
public const DELETE = 'CHILL_PERSON_DOCUMENT_DELETE';
public const SEE = 'CHILL_PERSON_DOCUMENT_SEE';
public const SEE_DETAILS = 'CHILL_PERSON_DOCUMENT_SEE_DETAILS';
public const UPDATE = 'CHILL_PERSON_DOCUMENT_UPDATE';
protected LoggerInterface $logger;
protected Security $security;
protected VoterHelperInterface $voterHelper;
public function __construct(
@@ -47,25 +60,34 @@ class PersonDocumentVoter extends AbstractChillVoter implements ProvideRoleHiera
self::SEE,
self::SEE_DETAILS,
self::UPDATE,
self::DELETE
self::DELETE,
];
}
public function getRolesWithHierarchy(): array
{
return ['PersonDocument' => $this->getRoles()];
}
public function getRolesWithoutScope(): array
{
return [];
}
protected function supports($attribute, $subject)
{
return $this->voterHelper->supports($attribute, $subject);
}
/**
*
* @param string $attribute
* @param PersonDocument $subject
* @param TokenInterface $token
* @return boolean
*
* @return bool
*/
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
{
$this->logger->debug(sprintf("Voting from %s class", self::class));
$this->logger->debug(sprintf('Voting from %s class', self::class));
if (!$token->getUser() instanceof User) {
return false;
@@ -78,14 +100,4 @@ class PersonDocumentVoter extends AbstractChillVoter implements ProvideRoleHiera
return $this->voterHelper->voteOnAttribute($attribute, $subject, $token);
}
public function getRolesWithoutScope(): array
{
return [];
}
public function getRolesWithHierarchy(): array
{
return ['PersonDocument' => $this->getRoles()];
}
}