8000 [FrameworkBundle][Cache] tag cache.app.taggable as a cache pool by xabbuh · Pull Request #35294 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle][Cache] tag cache.app.taggable as a cache pool #35294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
tag cache.app.taggable as a cache pool
With this change the CacheCollectorPass will be able to decorate the
TagAwareAdapter and thus injects a traceable cache when a service
argument's type declaration asks for a TagAwareCacheInterface
implementation.
  • Loading branch information
xabbuh committed Mar 28, 2020
commit 05ed5e5a0fd519dc8bd5610fa4a11f5dec8e41d3
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

<service id="cache.app.taggable" class="Symfony\Component\Cache\Adapter\TagAwareAdapter">
<argument type="service" id="cache.app" />
<tag name="cache.pool" />
</service>

<service id="cache.system" parent="cache.adapter.system" public="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Cache\Adapter\AbstractAdapter;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\ChainAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -155,11 +156,12 @@ public function process(ContainerBuilder $container)
if ($tags[0][$attr]) {
$pool->addTag($this->kernelResetTag, ['method' => $tags[0][$attr]]);
}
} elseif ('namespace' !== $attr || ArrayAdapter::class !== $class) {
} elseif (('namespace' !== $attr || ArrayAdapter::class !== $class) && TagAwareAdapter::class !== $class && !is_subclass_of($class, TagAwareAdapter::class)) {
$pool->replaceArgument($i++, $tags[0][$attr]);
}
unset($tags[0][$attr]);
}

if (!empty($tags[0])) {
throw new InvalidArgumentException(sprintf('Invalid "%s" tag for service "%s": accepted attributes are "clearer", "provider", "name", "namespace", "default_lifetime" and "reset", found "%s".', $this->cachePoolTag, $id, implode('", "', array_keys($tags[0]))));
}
Expand Down
0