[Security] use 'database_connection' as default connection for ACL
This commit is contained in:
parent
22947da18d
commit
1a0742003f
@ -1,67 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Bundle\DoctrineBundle\Security;
|
|
||||||
|
|
||||||
use Doctrine\Common\Collections\Collection;
|
|
||||||
use Symfony\Component\Security\Acl\Model\AclProviderInterface;
|
|
||||||
use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface;
|
|
||||||
use Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This service caches ACLs for an entire collection
|
|
||||||
*
|
|
||||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
|
||||||
*/
|
|
||||||
class AclCollectionCache
|
|
||||||
{
|
|
||||||
protected $aclProvider;
|
|
||||||
protected $objectIdentityRetrievalStrategy;
|
|
||||||
protected $securityIdentityRetrievalStrategy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param AclProviderInterface $aclProvider
|
|
||||||
* @param ObjectIdentityRetrievalStrategy $oidRetrievalStrategy
|
|
||||||
* @param SecurityIdentityRetrievalStrategy $sidRetrievalStrategy
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct(AclProviderInterface $aclProvider, ObjectIdentityRetrievalStrategyInterface $oidRetrievalStrategy, SecurityIdentityRetrievalStrategyInterface $sidRetrievalStrategy)
|
|
||||||
{
|
|
||||||
$this->aclProvider = $aclProvider;
|
|
||||||
$this->objectIdentityRetrievalStrategy = $oidRetrievalStrategy;
|
|
||||||
$this->securityIdentityRetrievalStrategy = $sidRetrievalStrategy;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Batch loads ACLs for an entire collection; thus, it reduces the number
|
|
||||||
* of required queries considerably.
|
|
||||||
*
|
|
||||||
* @param Collection $collection
|
|
||||||
* @param array $tokens an array of TokenInterface implementations
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function cache(Collection $collection, array $tokens = array())
|
|
||||||
{
|
|
||||||
$sids = array();
|
|
||||||
foreach ($tokens as $token) {
|
|
||||||
$sids = array_merge($sids, $this->securityIdentityRetrievalStrategy->getSecurityIdentities($token));
|
|
||||||
}
|
|
||||||
|
|
||||||
$oids = array();
|
|
||||||
foreach ($collection as $domainObject) {
|
|
||||||
$oids[] = $this->objectIdentityRetrievalStrategy->getObjectIdentity($domainObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->aclProvider->findAcls($oids, $sids);
|
|
||||||
}
|
|
||||||
}
|
|
@ -213,10 +213,6 @@ class Configuration
|
|||||||
->scalarNode('class')->isRequired()->cannotBeEmpty()->end()
|
->scalarNode('class')->isRequired()->cannotBeEmpty()->end()
|
||||||
->scalarNode('property')->defaultNull()->end()
|
->scalarNode('property')->defaultNull()->end()
|
||||||
->end()
|
->end()
|
||||||
->arrayNode('document')
|
|
||||||
->scalarNode('class')->isRequired()->cannotBeEmpty()->end()
|
|
||||||
->scalarNode('property')->defaultNull()->end()
|
|
||||||
->end()
|
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
;
|
;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
<service id="security.acl.dbal.connection" alias="doctrine.dbal.default_connection" />
|
<service id="security.acl.dbal.connection" alias="database_connection" />
|
||||||
|
|
||||||
<service id="security.acl.object_identity_retrieval_strategy" class="%security.acl.object_identity_retrieval_strategy.class%" public="false"></service>
|
<service id="security.acl.object_identity_retrieval_strategy" class="%security.acl.object_identity_retrieval_strategy.class%" public="false"></service>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user