Mercurial > hg > isophonics-drupal-site
diff core/lib/Drupal/Core/Plugin/PluginManagerPass.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/lib/Drupal/Core/Plugin/PluginManagerPass.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,28 @@ +<?php + +namespace Drupal\Core\Plugin; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +/** + * Registers plugin managers to the plugin.cache_clearer service. + */ +class PluginManagerPass implements CompilerPassInterface { + + /** + * {@inheritdoc} + */ + public function process(ContainerBuilder $container) { + $cache_clearer_definition = $container->getDefinition('plugin.cache_clearer'); + foreach ($container->getDefinitions() as $service_id => $definition) { + if (strpos($service_id, 'plugin.manager.') === 0 || $definition->hasTag('plugin_manager_cache_clear')) { + if (is_subclass_of($definition->getClass(), '\Drupal\Component\Plugin\Discovery\CachedDiscoveryInterface')) { + $cache_clearer_definition->addMethodCall('addCachedDiscovery', [new Reference($service_id)]); + } + } + } + } + +}