mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix: Autowire and autoconfigure the new service.
This commit is contained in:
parent
1509fcc2e9
commit
7a07b8bef7
@ -1,44 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
|
||||||
* Copyright (C) 2018 Julien Fastré <julien.fastre@champs-libres.coop>
|
declare(strict_types=1);
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
namespace Chill\MainBundle\Security\Authorization;
|
namespace Chill\MainBundle\Security\Authorization;
|
||||||
|
|
||||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
|
||||||
use Chill\MainBundle\Entity\User;
|
use Chill\MainBundle\Entity\User;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
|
||||||
*/
|
|
||||||
class ChillExportVoter extends Voter
|
class ChillExportVoter extends Voter
|
||||||
{
|
{
|
||||||
const EXPORT = 'chill_export';
|
public const EXPORT = 'chill_export';
|
||||||
|
|
||||||
/**
|
protected AuthorizationHelperInterface $authorizationHelper;
|
||||||
*
|
|
||||||
* @var AuthorizationHelper
|
|
||||||
*/
|
|
||||||
protected $authorizationHelper;
|
|
||||||
|
|
||||||
public function __construct(AuthorizationHelper $authorizationHelper)
|
public function __construct(AuthorizationHelperInterface $authorizationHelper)
|
||||||
{
|
{
|
||||||
$this->authorizationHelper = $authorizationHelper;
|
$this->authorizationHelper = $authorizationHelper;
|
||||||
}
|
}
|
||||||
@ -54,9 +30,6 @@ class ChillExportVoter extends Voter
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$centers = $this->authorizationHelper
|
return [] !== $this->authorizationHelper->getReachableCenters($token->getUser(), $attribute);
|
||||||
->getReachableCenters($token->getUser(), new Role($attribute));
|
|
||||||
|
|
||||||
return count($centers) > 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,15 @@ services:
|
|||||||
autowire: true
|
autowire: true
|
||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
|
|
||||||
# do not autowire the directory Security/Resolver
|
|
||||||
Chill\MainBundle\Security\Resolver\CenterResolverDispatcher:
|
Chill\MainBundle\Security\Resolver\CenterResolverDispatcher:
|
||||||
arguments:
|
arguments:
|
||||||
- !tagged_iterator chill_main.center_resolver
|
- !tagged_iterator chill_main.center_resolver
|
||||||
|
|
||||||
|
Chill\MainBundle\Security\Resolver\CenterResolverManager:
|
||||||
|
arguments:
|
||||||
|
- !tagged_iterator chill_main.center_resolver
|
||||||
|
Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface: '@Chill\MainBundle\Security\Resolver\CenterResolverManager'
|
||||||
|
|
||||||
Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher:
|
Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher:
|
||||||
arguments:
|
arguments:
|
||||||
- !tagged_iterator chill_main.scope_resolver
|
- !tagged_iterator chill_main.scope_resolver
|
||||||
@ -20,7 +24,6 @@ services:
|
|||||||
|
|
||||||
Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory: ~
|
Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory: ~
|
||||||
|
|
||||||
# do not autowire the directory Security/Resolver
|
|
||||||
Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface: '@Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory'
|
Chill\MainBundle\Security\Authorization\VoterHelperFactoryInterface: '@Chill\MainBundle\Security\Authorization\DefaultVoterHelperFactory'
|
||||||
|
|
||||||
chill.main.security.authorization.helper:
|
chill.main.security.authorization.helper:
|
||||||
@ -40,8 +43,6 @@ services:
|
|||||||
Symfony\Component\Security\Core\User\UserProviderInterface: "@chill.main.user_provider"
|
Symfony\Component\Security\Core\User\UserProviderInterface: "@chill.main.user_provider"
|
||||||
|
|
||||||
Chill\MainBundle\Security\Authorization\ChillExportVoter:
|
Chill\MainBundle\Security\Authorization\ChillExportVoter:
|
||||||
arguments:
|
|
||||||
$authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper'
|
|
||||||
tags:
|
tags:
|
||||||
- { name: security.voter }
|
- { name: security.voter }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user