Skip to content

Commit ce28a86

Browse files
feature symfony#16838 [PropertyAccess] Add PSR-6 cache (dunglas)
This PR was squashed before being merged into the 3.2-dev branch (closes symfony#16838). Discussion ---------- [PropertyAccess] Add PSR-6 cache | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a Follow symfony#16294 Commits ------- 4ccabcd [PropertyAccess] Add PSR-6 cache
2 parents 4256b68 + 4ccabcd commit ce28a86

File tree

7 files changed

+296
-117
lines changed

7 files changed

+296
-117
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;
1313

1414
use Doctrine\Common\Annotations\Reader;
15+
use Symfony\Component\Cache\Adapter\AdapterInterface;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\ContainerInterface;
1718
use Symfony\Component\DependencyInjection\Definition;
@@ -24,6 +25,7 @@
2425
use Symfony\Component\Finder\Finder;
2526
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2627
use Symfony\Component\Config\FileLocator;
28+
use Symfony\Component\PropertyAccess\PropertyAccessor;
2729
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
2830
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
2931
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
@@ -1062,6 +1064,15 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
10621064
$container->setDefinition($name, $definition);
10631065
}
10641066

1067+
if (method_exists(PropertyAccessor::class, 'createCache')) {
1068+
$propertyAccessDefinition = $container->register('cache.property_access', AdapterInterface::class);
1069+
$propertyAccessDefinition->setPublic(false);
1070+
$propertyAccessDefinition->setFactory(array(PropertyAccessor::class, 'createCache'));
1071+
$propertyAccessDefinition->setArguments(array(null, null, $version, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)));
1072+
$propertyAccessDefinition->addTag('cache.pool', array('clearer' => 'cache.default_clearer'));
1073+
$propertyAccessDefinition->addTag('monolog.logger', array('channel' => 'cache'));
1074+
}
1075+
10651076
$this->addClassesToCompile(array(
10661077
'Psr\Cache\CacheItemInterface',
10671078
'Psr\Cache\CacheItemPoolInterface',

src/Symfony/Bundle/FrameworkBundle/Resources/config/property_access.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<service id="property_accessor" class="Symfony\Component\PropertyAccess\PropertyAccessor" >
99
<argument /> <!-- magicCall, set by the extension -->
1010
<argument /> <!-- throwExceptionOnInvalidIndex, set by the extension -->
11+
<argument type="service" id="cache.property_access" on-invalid="ignore" />
1112
</service>
1213
</services>
1314
</container>

0 commit comments

Comments
 (0)