Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions DependencyInjection/MarkupAddressingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\Kernel;

/**
* This is the class that loads and manages your bundle configuration
Expand All @@ -28,6 +30,7 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');

$this->setSharedServices($container);
$this->loadCountryPostalCodeOverrides($config, $container);
}

Expand Down Expand Up @@ -61,4 +64,18 @@ private function loadRequireStrictRegions(array $config, ContainerBuilder $conta
{
$container->setParameter('markup_addressing.require_strict_regions', $config['require_strict_regions']);
}

private function setSharedServices(ContainerBuilder $container)
{
$sharedServiceIds = ['markup_addressing.twig.internal'];
$isLegacy = version_compare(Kernel::VERSION, '2.8', '<');
foreach ($sharedServiceIds as $sharedServiceId) {
$definition = $container->getDefinition($sharedServiceId);
if (!$isLegacy) {
$definition->setShared(true);
} else {
$definition->setScope(ContainerInterface::SCOPE_PROTOTYPE, false);
}
}
}
}
1 change: 0 additions & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ services:
- []
calls:
- [ addExtension, [ '@markup_addressing.country_name.extension' ] ]
scope: prototype
markup_addressing.twig.provider:
class: 'Markup\Addressing\Provider\KeyedEnvironmentServiceProvider'
arguments:
Expand Down