Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feature #16838 [PropertyAccess] Add PSR-6 cache (dunglas)
This PR was squashed before being merged into the 3.2-dev branch (closes #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 #16294

Commits
-------

4ccabcd [PropertyAccess] Add PSR-6 cache
  • Loading branch information
nicolas-grekas committed Jun 8, 2016
2 parents 4256b68 + 4ccabcd commit ce28a86
Show file tree
Hide file tree
Showing 7 changed files with 296 additions and 117 deletions.
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\DependencyInjection;

use Doctrine\Common\Annotations\Reader;
use Symfony\Component\Cache\Adapter\AdapterInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
Expand All @@ -24,6 +25,7 @@
use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\PropertyAccess\PropertyAccessor;
use Symfony\Component\Serializer\Mapping\Factory\CacheClassMetadataFactory;
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
Expand Down Expand Up @@ -1062,6 +1064,15 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
$container->setDefinition($name, $definition);
}

if (method_exists(PropertyAccessor::class, 'createCache')) {
$propertyAccessDefinition = $container->register('cache.property_access', AdapterInterface::class);
$propertyAccessDefinition->setPublic(false);
$propertyAccessDefinition->setFactory(array(PropertyAccessor::class, 'createCache'));
$propertyAccessDefinition->setArguments(array(null, null, $version, new Reference('logger', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)));
$propertyAccessDefinition->addTag('cache.pool', array('clearer' => 'cache.default_clearer'));
$propertyAccessDefinition->addTag('monolog.logger', array('channel' => 'cache'));
}

$this->addClassesToCompile(array(
'Psr\Cache\CacheItemInterface',
'Psr\Cache\CacheItemPoolInterface',
Expand Down
Expand Up @@ -8,6 +8,7 @@
<service id="property_accessor" class="Symfony\Component\PropertyAccess\PropertyAccessor" >
<argument /> <!-- magicCall, set by the extension -->
<argument /> <!-- throwExceptionOnInvalidIndex, set by the extension -->
<argument type="service" id="cache.property_access" on-invalid="ignore" />
</service>
</services>
</container>

0 comments on commit ce28a86

Please sign in to comment.