Skip to content
Snippets Groups Projects

Issue #3464388: SDC *.component.yml metadata is cached aggressively, gets in the way of component development

Open Issue #3464388: SDC *.component.yml metadata is cached aggressively, gets in the way of component development
Open Víctor Dorado requested to merge issue/drupal-3464388:3464388-sdc-metadata-cache into 11.x
6 files
+ 155
1
Compare changes
  • Side-by-side
  • Inline
Files
6
@@ -21,6 +21,7 @@
use Drupal\Core\Render\Component\Exception\ComponentNotFoundException;
use Drupal\Core\Render\Component\Exception\IncompatibleComponentSchema;
use Drupal\Core\Plugin\Discovery\DirectoryWithMetadataPluginDiscovery;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines a plugin manager to deal with components.
@@ -62,6 +63,8 @@ class ComponentPluginManager extends DefaultPluginManager implements Categorizin
* The compatibility checker.
* @param \Drupal\Core\Theme\Component\ComponentValidator $componentValidator
* The component validator.
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The container.
* @param string $appRoot
* The application root.
*/
@@ -75,6 +78,7 @@ public function __construct(
protected FileSystemInterface $fileSystem,
protected SchemaCompatibilityChecker $compatibilityChecker,
protected ComponentValidator $componentValidator,
protected ContainerInterface $container,
protected string $appRoot,
) {
// We are skipping the call to the parent constructor to avoid initializing
@@ -124,6 +128,21 @@ public function createInstance($plugin_id, array $configuration = []): Component
}
}
/**
* {@inheritdoc}
*/
public function getDefinitions(): array {
$twig_config = $this->container->getParameter('twig.config');
$twig_debug = $twig_config['debug'] ?? NULL;
$twig_cache = $twig_config['cache'] ?? NULL;
if ($twig_debug === TRUE || $twig_cache === FALSE) {
$this->definitions = $this->findDefinitions();
return $this->definitions;
}
return parent::getDefinitions();
}
/**
* Gets a component for rendering.
*
Loading