[Lock] Move configuration to PHP
This commit is contained in:
parent
188a9850df
commit
7882cd5527
@ -390,7 +390,7 @@ class FrameworkExtension extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isConfigEnabled($container, $config['lock'])) {
|
if ($this->isConfigEnabled($container, $config['lock'])) {
|
||||||
$this->registerLockConfiguration($config['lock'], $container, $loader);
|
$this->registerLockConfiguration($config['lock'], $container, $phpLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isConfigEnabled($container, $config['web_link'])) {
|
if ($this->isConfigEnabled($container, $config['web_link'])) {
|
||||||
@ -1568,9 +1568,9 @@ class FrameworkExtension extends Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function registerLockConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
private function registerLockConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader)
|
||||||
{
|
{
|
||||||
$loader->load('lock.xml');
|
$loader->load('lock.php');
|
||||||
|
|
||||||
foreach ($config['resources'] as $resourceName => $resourceStores) {
|
foreach ($config['resources'] as $resourceName => $resourceStores) {
|
||||||
if (0 === \count($resourceStores)) {
|
if (0 === \count($resourceStores)) {
|
||||||
|
30
src/Symfony/Bundle/FrameworkBundle/Resources/config/lock.php
Normal file
30
src/Symfony/Bundle/FrameworkBundle/Resources/config/lock.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the Symfony package.
|
||||||
|
*
|
||||||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
|
||||||
|
|
||||||
|
use Symfony\Component\Lock\LockFactory;
|
||||||
|
use Symfony\Component\Lock\Store\CombinedStore;
|
||||||
|
use Symfony\Component\Lock\Strategy\ConsensusStrategy;
|
||||||
|
|
||||||
|
return static function (ContainerConfigurator $container) {
|
||||||
|
$container->services()
|
||||||
|
->set('lock.store.combined.abstract', CombinedStore::class)->abstract()
|
||||||
|
->args([abstract_arg('List of stores'), service('lock.strategy.majority')])
|
||||||
|
|
||||||
|
->set('lock.strategy.majority', ConsensusStrategy::class)
|
||||||
|
|
||||||
|
->set('lock.factory.abstract', LockFactory::class)->abstract()
|
||||||
|
->args([abstract_arg('Store')])
|
||||||
|
->call('setLogger', [service('logger')->ignoreOnInvalid()])
|
||||||
|
->tag('monolog.logger', ['channel' => 'lock'])
|
||||||
|
;
|
||||||
|
};
|
@ -1,26 +0,0 @@
|
|||||||
<?xml version="1.0" ?>
|
|
||||||
|
|
||||||
<container xmlns="http://symfony.com/schema/dic/services"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
|
|
||||||
|
|
||||||
<services>
|
|
||||||
<defaults public="false" />
|
|
||||||
|
|
||||||
<service id="lock.store.combined.abstract" class="Symfony\Component\Lock\Store\CombinedStore" abstract="true">
|
|
||||||
<argument /> <!-- List of stores -->
|
|
||||||
<argument type="service" id="lock.strategy.majority" /> <!-- Strategy -->
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<service id="lock.strategy.majority" class="Symfony\Component\Lock\Strategy\ConsensusStrategy" />
|
|
||||||
|
|
||||||
<service id="lock.factory.abstract" class="Symfony\Component\Lock\LockFactory" abstract="true">
|
|
||||||
<tag name="monolog.logger" channel="lock" />
|
|
||||||
<argument /> <!-- Store -->
|
|
||||||
<call method="setLogger">
|
|
||||||
<argument type="service" id="logger" on-invalid="ignore" />
|
|
||||||
</call>
|
|
||||||
</service>
|
|
||||||
|
|
||||||
</services>
|
|
||||||
</container>
|
|
Reference in New Issue
Block a user