mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-26 09:33:50 +00:00
DX: apply rector rules up to php8.0
This commit is contained in:
@@ -34,28 +34,8 @@ use function get_class;
|
||||
*/
|
||||
class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
{
|
||||
private CenterResolverManagerInterface $centerResolverManager;
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
private ParentRoleHelper $parentRoleHelper;
|
||||
|
||||
private ScopeResolverDispatcher $scopeResolverDispatcher;
|
||||
|
||||
private UserACLAwareRepositoryInterface $userACLAwareRepository;
|
||||
|
||||
public function __construct(
|
||||
CenterResolverManagerInterface $centerResolverManager,
|
||||
LoggerInterface $logger,
|
||||
ScopeResolverDispatcher $scopeResolverDispatcher,
|
||||
UserACLAwareRepositoryInterface $userACLAwareRepository,
|
||||
ParentRoleHelper $parentRoleHelper
|
||||
) {
|
||||
$this->centerResolverManager = $centerResolverManager;
|
||||
$this->logger = $logger;
|
||||
$this->scopeResolverDispatcher = $scopeResolverDispatcher;
|
||||
$this->userACLAwareRepository = $userACLAwareRepository;
|
||||
$this->parentRoleHelper = $parentRoleHelper;
|
||||
public function __construct(private CenterResolverManagerInterface $centerResolverManager, private LoggerInterface $logger, private ScopeResolverDispatcher $scopeResolverDispatcher, private UserACLAwareRepositoryInterface $userACLAwareRepository, private ParentRoleHelper $parentRoleHelper)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,9 +43,8 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
*
|
||||
* @param User $user The user
|
||||
* @param array $centers a list of centers which are going to be filtered
|
||||
* @param mixed $role
|
||||
*/
|
||||
public function filterReachableCenters(User $user, array $centers, $role): array
|
||||
public function filterReachableCenters(User $user, array $centers, mixed $role): array
|
||||
{
|
||||
$results = [];
|
||||
|
||||
@@ -85,12 +64,10 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
/**
|
||||
* @deprecated use UserACLAwareRepositoryInterface::findUsersByReachedACL instead
|
||||
*
|
||||
* @param array|Center|Center[] $center
|
||||
* @param array|Scope|Scope[]|null $scope
|
||||
*
|
||||
* @return User[]
|
||||
*/
|
||||
public function findUsersReaching(string $role, $center, $scope = null, bool $onlyEnabled = true): array
|
||||
public function findUsersReaching(string $role, array|\Chill\MainBundle\Entity\Center $center, array|\Chill\MainBundle\Entity\Scope|null $scope = null, bool $onlyEnabled = true): array
|
||||
{
|
||||
return $this->userACLAwareRepository
|
||||
->findUsersByReachedACL($role, $center, $scope, $onlyEnabled);
|
||||
@@ -155,12 +132,10 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
/**
|
||||
* Return all reachable circle for a given user, center and role.
|
||||
*
|
||||
* @param Role|string $role
|
||||
* @param Center|Center[] $center
|
||||
*
|
||||
* @return Scope[]
|
||||
*/
|
||||
public function getReachableCircles(UserInterface $user, $role, $center)
|
||||
public function getReachableCircles(UserInterface $user, \Symfony\Component\Security\Core\Role\Role|string $role, \Chill\MainBundle\Entity\Center|array $center)
|
||||
{
|
||||
$scopes = [];
|
||||
|
||||
@@ -210,7 +185,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
*
|
||||
* @param Center|Center[] $center May be an array of center
|
||||
*/
|
||||
public function userCanReachCenter(User $user, $center): bool
|
||||
public function userCanReachCenter(User $user, \Chill\MainBundle\Entity\Center|array $center): bool
|
||||
{
|
||||
if ($center instanceof Traversable) {
|
||||
foreach ($center as $c) {
|
||||
@@ -236,7 +211,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
sprintf(
|
||||
'The entity given is not an instance of %s, %s given',
|
||||
Center::class,
|
||||
get_class($center)
|
||||
$center::class
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -252,7 +227,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
*
|
||||
* @return bool true if the user has access
|
||||
*/
|
||||
public function userHasAccess(User $user, $entity, $attribute)
|
||||
public function userHasAccess(User $user, mixed $entity, \Symfony\Component\Security\Core\Role\Role|string $attribute)
|
||||
{
|
||||
$centers = $this->centerResolverManager->resolveCenters($entity);
|
||||
|
||||
|
@@ -17,14 +17,8 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class AuthorizationHelperForCurrentUser implements AuthorizationHelperForCurrentUserInterface
|
||||
{
|
||||
private AuthorizationHelperInterface $authorizationHelper;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(AuthorizationHelperInterface $authorizationHelper, Security $security)
|
||||
public function __construct(private AuthorizationHelperInterface $authorizationHelper, private Security $security)
|
||||
{
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function getReachableCenters(string $role, ?Scope $scope = null): array
|
||||
|
@@ -18,20 +18,8 @@ use function in_array;
|
||||
|
||||
final class DefaultVoterHelper implements VoterHelperInterface
|
||||
{
|
||||
private AuthorizationHelper $authorizationHelper;
|
||||
|
||||
private CenterResolverDispatcherInterface $centerResolverDispatcher;
|
||||
|
||||
private array $configuration = [];
|
||||
|
||||
public function __construct(
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
CenterResolverDispatcherInterface $centerResolverDispatcher,
|
||||
array $configuration
|
||||
) {
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->centerResolverDispatcher = $centerResolverDispatcher;
|
||||
$this->configuration = $configuration;
|
||||
public function __construct(private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher, private array $configuration)
|
||||
{
|
||||
}
|
||||
|
||||
public function supports($attribute, $subject): bool
|
||||
|
@@ -15,16 +15,8 @@ use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
||||
|
||||
class DefaultVoterHelperFactory implements VoterHelperFactoryInterface
|
||||
{
|
||||
protected AuthorizationHelper $authorizationHelper;
|
||||
|
||||
protected CenterResolverDispatcherInterface $centerResolverDispatcher;
|
||||
|
||||
public function __construct(
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
CenterResolverDispatcherInterface $centerResolverDispatcher
|
||||
) {
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->centerResolverDispatcher = $centerResolverDispatcher;
|
||||
public function __construct(protected AuthorizationHelper $authorizationHelper, protected CenterResolverDispatcherInterface $centerResolverDispatcher)
|
||||
{
|
||||
}
|
||||
|
||||
public function generate($context): VoterGeneratorInterface
|
||||
|
@@ -15,18 +15,10 @@ use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
|
||||
|
||||
final class DefaultVoterHelperGenerator implements VoterGeneratorInterface
|
||||
{
|
||||
private AuthorizationHelper $authorizationHelper;
|
||||
|
||||
private CenterResolverDispatcherInterface $centerResolverDispatcher;
|
||||
|
||||
private array $configuration = [];
|
||||
|
||||
public function __construct(
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
CenterResolverDispatcherInterface $centerResolverDispatcher
|
||||
) {
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->centerResolverDispatcher = $centerResolverDispatcher;
|
||||
public function __construct(private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher)
|
||||
{
|
||||
}
|
||||
|
||||
public function addCheckFor(?string $subject, array $attributes): self
|
||||
|
@@ -29,14 +29,8 @@ class EntityWorkflowVoter extends Voter
|
||||
|
||||
public const SHOW_ENTITY_LINK = 'CHILL_MAIN_WORKFLOW_LINK_SHOW';
|
||||
|
||||
private EntityWorkflowManager $manager;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(EntityWorkflowManager $manager, Security $security)
|
||||
public function __construct(private EntityWorkflowManager $manager, private Security $security)
|
||||
{
|
||||
$this->manager = $manager;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
|
@@ -53,35 +53,22 @@ final class NotificationVoter extends Voter
|
||||
}
|
||||
|
||||
if ($subject instanceof Notification) {
|
||||
switch ($attribute) {
|
||||
case self::COMMENT_ADD:
|
||||
return false === $subject->isSystem() && (
|
||||
$subject->getAddressees()->contains($user) || $subject->getSender() === $user
|
||||
);
|
||||
|
||||
case self::NOTIFICATION_SEE:
|
||||
case self::NOTIFICATION_TOGGLE_READ_STATUS:
|
||||
return $subject->getSender() === $user || $subject->getAddressees()->contains($user);
|
||||
|
||||
case self::NOTIFICATION_UPDATE:
|
||||
return $subject->getSender() === $user && false === $subject->isSystem();
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("this subject {$attribute} is not implemented");
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::COMMENT_ADD => false === $subject->isSystem() && (
|
||||
$subject->getAddressees()->contains($user) || $subject->getSender() === $user
|
||||
),
|
||||
self::NOTIFICATION_SEE, self::NOTIFICATION_TOGGLE_READ_STATUS => $subject->getSender() === $user || $subject->getAddressees()->contains($user),
|
||||
self::NOTIFICATION_UPDATE => $subject->getSender() === $user && false === $subject->isSystem(),
|
||||
default => throw new UnexpectedValueException("this subject {$attribute} is not implemented"),
|
||||
};
|
||||
} elseif ($subject instanceof NotificationComment) {
|
||||
switch ($attribute) {
|
||||
case self::COMMENT_ADD:
|
||||
return false === $subject->getNotification()->isSystem() && (
|
||||
$subject->getNotification()->getAddressees()->contains($user) || $subject->getNotification()->getSender() === $user
|
||||
);
|
||||
|
||||
case self::COMMENT_EDIT:
|
||||
return $subject->getCreatedBy() === $user && false === $subject->getNotification()->isSystem();
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("this subject {$attribute} is not implemented");
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::COMMENT_ADD => false === $subject->getNotification()->isSystem() && (
|
||||
$subject->getNotification()->getAddressees()->contains($user) || $subject->getNotification()->getSender() === $user
|
||||
),
|
||||
self::COMMENT_EDIT => $subject->getCreatedBy() === $user && false === $subject->getNotification()->isSystem(),
|
||||
default => throw new UnexpectedValueException("this subject {$attribute} is not implemented"),
|
||||
};
|
||||
}
|
||||
|
||||
throw new UnexpectedValueException();
|
||||
|
@@ -38,15 +38,9 @@ class SavedExportVoter extends Voter
|
||||
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
|
||||
{
|
||||
/** @var SavedExport $subject */
|
||||
switch ($attribute) {
|
||||
case self::DELETE:
|
||||
case self::EDIT:
|
||||
case self::GENERATE:
|
||||
return $subject->getUser() === $token->getUser();
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException('attribute not supported: ' . $attribute);
|
||||
}
|
||||
return match ($attribute) {
|
||||
self::DELETE, self::EDIT, self::GENERATE => $subject->getUser() === $token->getUser(),
|
||||
default => throw new UnexpectedValueException('attribute not supported: ' . $attribute),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -21,17 +21,11 @@ use function is_object;
|
||||
|
||||
class WorkflowEntityDeletionVoter extends Voter
|
||||
{
|
||||
private EntityWorkflowRepository $entityWorkflowRepository;
|
||||
|
||||
/**
|
||||
* @var iterable|EntityWorkflowHandlerInterface[]
|
||||
* @param \Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface[] $handlers
|
||||
*/
|
||||
private iterable $handlers;
|
||||
|
||||
public function __construct($handlers, EntityWorkflowRepository $entityWorkflowRepository)
|
||||
public function __construct(private $handlers, private EntityWorkflowRepository $entityWorkflowRepository)
|
||||
{
|
||||
$this->handlers = $handlers;
|
||||
$this->entityWorkflowRepository = $entityWorkflowRepository;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
|
@@ -31,13 +31,10 @@ class ParentRoleHelper
|
||||
*/
|
||||
protected array $hierarchy;
|
||||
|
||||
protected RoleHierarchyInterface $roleHierarchy;
|
||||
|
||||
public function __construct(
|
||||
RoleHierarchyInterface $roleHierarchy,
|
||||
protected RoleHierarchyInterface $roleHierarchy,
|
||||
ParameterBagInterface $parameterBag
|
||||
) {
|
||||
$this->roleHierarchy = $roleHierarchy;
|
||||
$this->hierarchy = $parameterBag->get('security.role_hierarchy.roles');
|
||||
}
|
||||
|
||||
|
@@ -22,21 +22,11 @@ class PasswordRecoverEvent extends Event
|
||||
|
||||
public const INVALID_TOKEN = 'chill_main.password_recover_invalid_token';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $ip;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $safelyGenerated;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $token;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
@@ -48,11 +38,9 @@ class PasswordRecoverEvent extends Event
|
||||
* @param type $ip
|
||||
* @param bool $safelyGenerated true if generated safely (from console command, etc.)
|
||||
*/
|
||||
public function __construct($token = null, ?User $user = null, $ip = null, bool $safelyGenerated = false)
|
||||
public function __construct(protected $token = null, ?User $user = null, protected $ip = null, bool $safelyGenerated = false)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->token = $token;
|
||||
$this->ip = $ip;
|
||||
$this->safelyGenerated = $safelyGenerated;
|
||||
}
|
||||
|
||||
@@ -69,10 +57,7 @@ class PasswordRecoverEvent extends Event
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User|null
|
||||
*/
|
||||
public function getUser()
|
||||
public function getUser(): ?\Chill\MainBundle\Entity\User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
@@ -80,67 +80,36 @@ class PasswordRecoverLocker
|
||||
*/
|
||||
public static function generateLockKey($usage, int $number, $discriminator = null)
|
||||
{
|
||||
switch ($usage) {
|
||||
case 'invalid_token_global':
|
||||
return sprintf('invalid_token_global_%d', $number);
|
||||
|
||||
case 'invalid_token_by_ip':
|
||||
return sprintf('invalid_token_ip_%s_%d', $discriminator, $number);
|
||||
|
||||
case 'ask_token_invalid_form_global':
|
||||
return sprintf('ask_token_invalid_form_global_%d', $number);
|
||||
|
||||
case 'ask_token_invalid_form_by_ip':
|
||||
return sprintf('ask_token_invalid_form_by_ip_%s_%d', $discriminator, $number);
|
||||
|
||||
case 'ask_token_success_by_user':
|
||||
return sprintf('ask_token_success_by_user_%s_%d', $discriminator->getId(), $number);
|
||||
|
||||
default:
|
||||
throw new LogicException('this usage is not implemented');
|
||||
}
|
||||
return match ($usage) {
|
||||
'invalid_token_global' => sprintf('invalid_token_global_%d', $number),
|
||||
'invalid_token_by_ip' => sprintf('invalid_token_ip_%s_%d', $discriminator, $number),
|
||||
'ask_token_invalid_form_global' => sprintf('ask_token_invalid_form_global_%d', $number),
|
||||
'ask_token_invalid_form_by_ip' => sprintf('ask_token_invalid_form_by_ip_%s_%d', $discriminator, $number),
|
||||
'ask_token_success_by_user' => sprintf('ask_token_success_by_user_%s_%d', $discriminator->getId(), $number),
|
||||
default => throw new LogicException('this usage is not implemented'),
|
||||
};
|
||||
}
|
||||
|
||||
public function getMax($usage)
|
||||
{
|
||||
switch ($usage) {
|
||||
case 'invalid_token_global':
|
||||
return self::MAX_INVALID_TOKEN_GLOBAL;
|
||||
|
||||
case 'invalid_token_by_ip':
|
||||
return self::MAX_INVALID_TOKEN_BY_IP;
|
||||
|
||||
case 'ask_token_invalid_form_global':
|
||||
return self::MAX_ASK_TOKEN_INVALID_FORM_GLOBAL;
|
||||
|
||||
case 'ask_token_invalid_form_by_ip':
|
||||
return self::MAX_ASK_TOKEN_INVALID_FORM_BY_IP;
|
||||
|
||||
case 'ask_token_success_by_user':
|
||||
return self::MAX_ASK_TOKEN_BY_USER;
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("this usage '{$usage}' is not yet implemented");
|
||||
}
|
||||
return match ($usage) {
|
||||
'invalid_token_global' => self::MAX_INVALID_TOKEN_GLOBAL,
|
||||
'invalid_token_by_ip' => self::MAX_INVALID_TOKEN_BY_IP,
|
||||
'ask_token_invalid_form_global' => self::MAX_ASK_TOKEN_INVALID_FORM_GLOBAL,
|
||||
'ask_token_invalid_form_by_ip' => self::MAX_ASK_TOKEN_INVALID_FORM_BY_IP,
|
||||
'ask_token_success_by_user' => self::MAX_ASK_TOKEN_BY_USER,
|
||||
default => throw new UnexpectedValueException("this usage '{$usage}' is not yet implemented"),
|
||||
};
|
||||
}
|
||||
|
||||
public function getTtl($usage)
|
||||
{
|
||||
switch ($usage) {
|
||||
case 'invalid_token_global':
|
||||
case 'invalid_token_by_ip':
|
||||
return self::INVALID_TOKEN_TTL;
|
||||
|
||||
case 'ask_token_invalid_form_global':
|
||||
case 'ask_token_invalid_form_by_ip':
|
||||
return self::ASK_TOKEN_INVALID_FORM_TTL;
|
||||
|
||||
case 'ask_token_success_by_user':
|
||||
return self::ASK_TOKEN_INVALID_FORM_TTL * 24;
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("this usage '{$usage}' is not yet implemented");
|
||||
}
|
||||
return match ($usage) {
|
||||
'invalid_token_global', 'invalid_token_by_ip' => self::INVALID_TOKEN_TTL,
|
||||
'ask_token_invalid_form_global', 'ask_token_invalid_form_by_ip' => self::ASK_TOKEN_INVALID_FORM_TTL,
|
||||
'ask_token_success_by_user' => self::ASK_TOKEN_INVALID_FORM_TTL * 24,
|
||||
default => throw new UnexpectedValueException("this usage '{$usage}' is not yet implemented"),
|
||||
};
|
||||
}
|
||||
|
||||
public function isLocked($usage, $discriminator = null)
|
||||
|
@@ -43,13 +43,10 @@ class TokenManager
|
||||
protected $logger;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @param string $secret
|
||||
*/
|
||||
protected $secret;
|
||||
|
||||
public function __construct($secret, LoggerInterface $logger)
|
||||
public function __construct(protected $secret, LoggerInterface $logger)
|
||||
{
|
||||
$this->secret = $secret;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
|
@@ -14,13 +14,10 @@ namespace Chill\MainBundle\Security\Resolver;
|
||||
final class CenterResolverDispatcher implements CenterResolverDispatcherInterface
|
||||
{
|
||||
/**
|
||||
* @var CenterResolverInterface[]
|
||||
* @param \Chill\MainBundle\Security\Resolver\CenterResolverInterface[] $resolvers
|
||||
*/
|
||||
private iterable $resolvers;
|
||||
|
||||
public function __construct(iterable $resolvers = [])
|
||||
public function __construct(private iterable $resolvers = [])
|
||||
{
|
||||
$this->resolvers = $resolvers;
|
||||
}
|
||||
|
||||
public function resolveCenter($entity, ?array $options = [])
|
||||
|
@@ -20,13 +20,10 @@ use function is_array;
|
||||
final class CenterResolverManager implements CenterResolverManagerInterface
|
||||
{
|
||||
/**
|
||||
* @var CenterResolverInterface[]
|
||||
* @param \Chill\MainBundle\Security\Resolver\CenterResolverInterface[] $resolvers
|
||||
*/
|
||||
private iterable $resolvers;
|
||||
|
||||
public function __construct(iterable $resolvers = [])
|
||||
public function __construct(private iterable $resolvers = [])
|
||||
{
|
||||
$this->resolvers = $resolvers;
|
||||
}
|
||||
|
||||
public function resolveCenters($entity, ?array $options = []): array
|
||||
@@ -51,7 +48,7 @@ final class CenterResolverManager implements CenterResolverManagerInterface
|
||||
'the return type of a %s should be an instance of %s, an array or null. Resolver is %s',
|
||||
CenterResolverInterface::class,
|
||||
Center::class,
|
||||
get_class($resolver)
|
||||
$resolver::class
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@@ -15,14 +15,8 @@ use Twig\TwigFilter;
|
||||
|
||||
final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension
|
||||
{
|
||||
private CenterResolverManagerInterface $centerResolverDispatcher;
|
||||
|
||||
private ScopeResolverDispatcher $scopeResolverDispatcher;
|
||||
|
||||
public function __construct(CenterResolverManagerInterface $centerResolverDispatcher, ScopeResolverDispatcher $scopeResolverDispatcher)
|
||||
public function __construct(private CenterResolverManagerInterface $centerResolverDispatcher, private ScopeResolverDispatcher $scopeResolverDispatcher)
|
||||
{
|
||||
$this->centerResolverDispatcher = $centerResolverDispatcher;
|
||||
$this->scopeResolverDispatcher = $scopeResolverDispatcher;
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
@@ -45,11 +39,9 @@ final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $entity
|
||||
*
|
||||
* @return Center|Center[]|null
|
||||
*/
|
||||
public function resolveCenter($entity, ?array $options = [])
|
||||
public function resolveCenter(mixed $entity, ?array $options = [])
|
||||
{
|
||||
return $this->centerResolverDispatcher->resolveCenters($entity, $options);
|
||||
}
|
||||
@@ -59,7 +51,7 @@ final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension
|
||||
*
|
||||
* @return array|\Chill\MainBundle\Entity\Scope|\Chill\MainBundle\Entity\Scope[]
|
||||
*/
|
||||
public function resolveScope($entity, ?array $options = [])
|
||||
public function resolveScope($entity, ?array $options = []): array|\Chill\MainBundle\Entity\Scope
|
||||
{
|
||||
return $this->scopeResolverDispatcher->resolveScope();
|
||||
}
|
||||
|
@@ -17,13 +17,10 @@ use Doctrine\Common\Collections\Collection;
|
||||
final class ScopeResolverDispatcher
|
||||
{
|
||||
/**
|
||||
* @var iterable|ScopeResolverInterface[]
|
||||
* @param \Chill\MainBundle\Security\Resolver\ScopeResolverInterface[] $resolvers
|
||||
*/
|
||||
private iterable $resolvers;
|
||||
|
||||
public function __construct(iterable $resolvers)
|
||||
public function __construct(private iterable $resolvers)
|
||||
{
|
||||
$this->resolvers = $resolvers;
|
||||
}
|
||||
|
||||
public function isConcerned($entity, ?array $options = []): bool
|
||||
@@ -42,7 +39,7 @@ final class ScopeResolverDispatcher
|
||||
*
|
||||
* @return iterable|Scope|Scope[]
|
||||
*/
|
||||
public function resolveScope($entity, ?array $options = [])
|
||||
public function resolveScope($entity, ?array $options = []): iterable|\Chill\MainBundle\Entity\Scope|array
|
||||
{
|
||||
foreach ($this->resolvers as $resolver) {
|
||||
if ($resolver->supports($entity, $options)) {
|
||||
|
@@ -35,8 +35,6 @@ class RoleProvider
|
||||
* Add a role provider.
|
||||
*
|
||||
* @internal This function is called by the dependency injector: it inject provider
|
||||
*
|
||||
* @param \Chill\MainBundle\Security\ProvideRoleInterface $provider
|
||||
*/
|
||||
public function addProvider(ProvideRoleInterface $provider)
|
||||
{
|
||||
|
@@ -21,11 +21,8 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||
|
||||
class UserProvider implements UserProviderInterface
|
||||
{
|
||||
protected EntityManagerInterface $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
public function __construct(protected EntityManagerInterface $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function loadUserByUsername($username): UserInterface
|
||||
|
Reference in New Issue
Block a user