mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-26 01:23:49 +00:00
Merge branch 'master' into upgrade-sf5
This commit is contained in:
@@ -18,4 +18,6 @@ use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
*
|
||||
* This abstract Voter provide generic methods to handle object specific to Chill
|
||||
*/
|
||||
abstract class AbstractChillVoter extends Voter implements ChillVoterInterface {}
|
||||
abstract class AbstractChillVoter extends Voter implements ChillVoterInterface
|
||||
{
|
||||
}
|
||||
|
@@ -34,7 +34,8 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
private readonly ScopeResolverDispatcher $scopeResolverDispatcher,
|
||||
private readonly UserACLAwareRepositoryInterface $userACLAwareRepository,
|
||||
private readonly ParentRoleHelper $parentRoleHelper
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter an array of centers, return only center which are reachable.
|
||||
@@ -60,7 +61,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
*
|
||||
* @return User[]
|
||||
*/
|
||||
public function findUsersReaching(string $role, array|\Chill\MainBundle\Entity\Center $center, array|\Chill\MainBundle\Entity\Scope $scope = null, bool $onlyEnabled = true): array
|
||||
public function findUsersReaching(string $role, array|Center $center, array|Scope|null $scope = null, bool $onlyEnabled = true): array
|
||||
{
|
||||
return $this->userACLAwareRepository
|
||||
->findUsersByReachedACL($role, $center, $scope, $onlyEnabled);
|
||||
@@ -85,7 +86,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
*
|
||||
* @return list<Center>
|
||||
*/
|
||||
public function getReachableCenters(UserInterface $user, string $role, Scope $scope = null): array
|
||||
public function getReachableCenters(UserInterface $user, string $role, ?Scope $scope = null): array
|
||||
{
|
||||
if (!$user instanceof User) {
|
||||
return [];
|
||||
@@ -125,7 +126,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
*
|
||||
* @return Scope[]
|
||||
*/
|
||||
public function getReachableCircles(UserInterface $user, string $role, array|\Chill\MainBundle\Entity\Center $center)
|
||||
public function getReachableCircles(UserInterface $user, string $role, array|Center $center)
|
||||
{
|
||||
$scopes = [];
|
||||
|
||||
@@ -167,7 +168,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
|
||||
*
|
||||
* @param Center|Center[] $center May be an array of center
|
||||
*/
|
||||
public function userCanReachCenter(User $user, array|\Chill\MainBundle\Entity\Center $center): bool
|
||||
public function userCanReachCenter(User $user, array|Center $center): bool
|
||||
{
|
||||
if ($center instanceof \Traversable) {
|
||||
foreach ($center as $c) {
|
||||
|
@@ -17,9 +17,11 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class AuthorizationHelperForCurrentUser implements AuthorizationHelperForCurrentUserInterface
|
||||
{
|
||||
public function __construct(private readonly AuthorizationHelperInterface $authorizationHelper, private readonly Security $security) {}
|
||||
public function __construct(private readonly AuthorizationHelperInterface $authorizationHelper, private readonly Security $security)
|
||||
{
|
||||
}
|
||||
|
||||
public function getReachableCenters(string $role, Scope $scope = null): array
|
||||
public function getReachableCenters(string $role, ?Scope $scope = null): array
|
||||
{
|
||||
if (!$this->security->getUser() instanceof User) {
|
||||
return [];
|
||||
|
@@ -22,7 +22,7 @@ interface AuthorizationHelperForCurrentUserInterface
|
||||
*
|
||||
* @return Center[]
|
||||
*/
|
||||
public function getReachableCenters(string $role, Scope $scope = null): array;
|
||||
public function getReachableCenters(string $role, ?Scope $scope = null): array;
|
||||
|
||||
/**
|
||||
* @param list<Center>|Center $center
|
||||
|
@@ -23,7 +23,7 @@ interface AuthorizationHelperInterface
|
||||
*
|
||||
* @return list<Center>
|
||||
*/
|
||||
public function getReachableCenters(UserInterface $user, string $role, Scope $scope = null): array;
|
||||
public function getReachableCenters(UserInterface $user, string $role, ?Scope $scope = null): array;
|
||||
|
||||
/**
|
||||
* @param Center|array<Center> $center
|
||||
|
@@ -14,4 +14,6 @@ namespace Chill\MainBundle\Security\Authorization;
|
||||
/**
|
||||
* Provides methods for compiling voter and build admin role fields.
|
||||
*/
|
||||
interface ChillVoterInterface {}
|
||||
interface ChillVoterInterface
|
||||
{
|
||||
}
|
||||
|
@@ -18,7 +18,8 @@ final readonly class DefaultVoterHelper implements VoterHelperInterface
|
||||
public function __construct(
|
||||
private AuthorizationHelper $authorizationHelper,
|
||||
private array $configuration
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function supports($attribute, $subject): bool
|
||||
{
|
||||
|
@@ -13,7 +13,9 @@ namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
class DefaultVoterHelperFactory implements VoterHelperFactoryInterface
|
||||
{
|
||||
public function __construct(protected AuthorizationHelper $authorizationHelper) {}
|
||||
public function __construct(protected AuthorizationHelper $authorizationHelper)
|
||||
{
|
||||
}
|
||||
|
||||
public function generate($context): VoterGeneratorInterface
|
||||
{
|
||||
|
@@ -15,7 +15,9 @@ final class DefaultVoterHelperGenerator implements VoterGeneratorInterface
|
||||
{
|
||||
private array $configuration = [];
|
||||
|
||||
public function __construct(private readonly AuthorizationHelper $authorizationHelper) {}
|
||||
public function __construct(private readonly AuthorizationHelper $authorizationHelper)
|
||||
{
|
||||
}
|
||||
|
||||
public function addCheckFor(?string $class, array $attributes): self
|
||||
{
|
||||
|
@@ -27,7 +27,9 @@ class EntityWorkflowVoter extends Voter
|
||||
|
||||
final public const SHOW_ENTITY_LINK = 'CHILL_MAIN_WORKFLOW_LINK_SHOW';
|
||||
|
||||
public function __construct(private readonly EntityWorkflowManager $manager, private readonly Security $security) {}
|
||||
public function __construct(private readonly EntityWorkflowManager $manager, private readonly Security $security)
|
||||
{
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
|
@@ -20,7 +20,9 @@ class WorkflowEntityDeletionVoter extends Voter
|
||||
/**
|
||||
* @param \Chill\MainBundle\Workflow\EntityWorkflowHandlerInterface[] $handlers
|
||||
*/
|
||||
public function __construct(private $handlers, private readonly EntityWorkflowRepository $entityWorkflowRepository) {}
|
||||
public function __construct(private $handlers, private readonly EntityWorkflowRepository $entityWorkflowRepository)
|
||||
{
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
|
@@ -30,7 +30,8 @@ class PasswordRecoverEvent extends \Symfony\Contracts\EventDispatcher\Event
|
||||
private readonly ?User $user = null,
|
||||
private $ip = null,
|
||||
private readonly bool $safelyGenerated = false,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
public function getIp()
|
||||
{
|
||||
|
@@ -20,7 +20,9 @@ class RecoverPasswordHelper
|
||||
{
|
||||
final public const RECOVER_PASSWORD_ROUTE = 'password_recover';
|
||||
|
||||
public function __construct(private readonly TokenManager $tokenManager, private readonly UrlGeneratorInterface $urlGenerator, private readonly MailerInterface $mailer) {}
|
||||
public function __construct(private readonly TokenManager $tokenManager, private readonly UrlGeneratorInterface $urlGenerator, private readonly MailerInterface $mailer)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $absolute
|
||||
|
@@ -16,7 +16,9 @@ final readonly class CenterResolverDispatcher implements CenterResolverDispatche
|
||||
/**
|
||||
* @param \Chill\MainBundle\Security\Resolver\CenterResolverInterface[] $resolvers
|
||||
*/
|
||||
public function __construct(private iterable $resolvers = []) {}
|
||||
public function __construct(private iterable $resolvers = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function resolveCenter($entity, ?array $options = [])
|
||||
{
|
||||
|
@@ -18,7 +18,9 @@ final readonly class CenterResolverManager implements CenterResolverManagerInter
|
||||
/**
|
||||
* @param \Chill\MainBundle\Security\Resolver\CenterResolverInterface[] $resolvers
|
||||
*/
|
||||
public function __construct(private iterable $resolvers = []) {}
|
||||
public function __construct(private iterable $resolvers = [])
|
||||
{
|
||||
}
|
||||
|
||||
public function resolveCenters($entity, ?array $options = []): array
|
||||
{
|
||||
|
@@ -15,7 +15,9 @@ use Twig\TwigFilter;
|
||||
|
||||
final class ResolverTwigExtension extends \Twig\Extension\AbstractExtension
|
||||
{
|
||||
public function __construct(private readonly CenterResolverManagerInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher) {}
|
||||
public function __construct(private readonly CenterResolverManagerInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher)
|
||||
{
|
||||
}
|
||||
|
||||
public function getFilters()
|
||||
{
|
||||
|
@@ -19,7 +19,9 @@ final readonly class ScopeResolverDispatcher
|
||||
/**
|
||||
* @param \Chill\MainBundle\Security\Resolver\ScopeResolverInterface[] $resolvers
|
||||
*/
|
||||
public function __construct(private iterable $resolvers) {}
|
||||
public function __construct(private iterable $resolvers)
|
||||
{
|
||||
}
|
||||
|
||||
public function isConcerned($entity, ?array $options = []): bool
|
||||
{
|
||||
@@ -35,7 +37,7 @@ final readonly class ScopeResolverDispatcher
|
||||
/**
|
||||
* @return Scope|iterable<Scope>|Scope|null
|
||||
*/
|
||||
public function resolveScope(mixed $entity, ?array $options = []): null|\Chill\MainBundle\Entity\Scope|iterable
|
||||
public function resolveScope(mixed $entity, ?array $options = []): iterable|Scope|null
|
||||
{
|
||||
foreach ($this->resolvers as $resolver) {
|
||||
if ($resolver->supports($entity, $options)) {
|
||||
|
@@ -21,7 +21,9 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||
|
||||
class UserProvider implements UserProviderInterface
|
||||
{
|
||||
public function __construct(protected EntityManagerInterface $em) {}
|
||||
public function __construct(protected EntityManagerInterface $em)
|
||||
{
|
||||
}
|
||||
|
||||
public function loadUserByUsername($username): UserInterface
|
||||
{
|
||||
|
Reference in New Issue
Block a user