Server IP : 23.254.227.96 / Your IP : 216.73.216.120 Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64 User : viralblo ( 1001) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/local/cwpsrv/var/services/pma/vendor/symfony/cache/DependencyInjection/ |
Upload File : |
<?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\Cache\DependencyInjection; use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface; use Symfony\Component\Cache\Adapter\TraceableAdapter; use Symfony\Component\Cache\Adapter\TraceableTagAwareAdapter; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; /** * Inject a data collector to all the cache services to be able to get detailed statistics. * * @author Tobias Nyholm <tobias.nyholm@gmail.com> */ class CacheCollectorPass implements CompilerPassInterface { private $dataCollectorCacheId; private $cachePoolTag; private $cachePoolRecorderInnerSuffix; public function __construct(string $dataCollectorCacheId = 'data_collector.cache', string $cachePoolTag = 'cache.pool', string $cachePoolRecorderInnerSuffix = '.recorder_inner') { $this->dataCollectorCacheId = $dataCollectorCacheId; $this->cachePoolTag = $cachePoolTag; $this->cachePoolRecorderInnerSuffix = $cachePoolRecorderInnerSuffix; } /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition($this->dataCollectorCacheId)) { return; } foreach ($container->findTaggedServiceIds($this->cachePoolTag) as $id => $attributes) { $poolName = $attributes[0]['name'] ?? $id; $this->addToCollector($id, $poolName, $container); } } private function addToCollector(string $id, string $name, ContainerBuilder $container) { $definition = $container->getDefinition($id); if ($definition->isAbstract()) { return; } $collectorDefinition = $container->getDefinition($this->dataCollectorCacheId); $recorder = new Definition(is_subclass_of($definition->getClass(), TagAwareAdapterInterface::class) ? TraceableTagAwareAdapter::class : TraceableAdapter::class); $recorder->setTags($definition->getTags()); if (!$definition->isPublic() || !$definition->isPrivate()) { $recorder->setPublic($definition->isPublic()); } $recorder->setArguments([new Reference($innerId = $id.$this->cachePoolRecorderInnerSuffix)]); $definition->setTags([]); $definition->setPublic(false); $container->setDefinition($innerId, $definition); $container->setDefinition($id, $recorder); // Tell the collector to add the new instance $collectorDefinition->addMethodCall('addInstance', [$name, new Reference($id)]); $collectorDefinition->setPublic(false); } }