VariantManager.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Drupal\Core\Display;
  3. use Drupal\Core\Cache\CacheBackendInterface;
  4. use Drupal\Core\Extension\ModuleHandlerInterface;
  5. use Drupal\Core\Plugin\DefaultPluginManager;
  6. /**
  7. * Manages discovery of display variant plugins.
  8. *
  9. * @see \Drupal\Core\Display\Annotation\DisplayVariant
  10. * @see \Drupal\Core\Display\VariantInterface
  11. * @see \Drupal\Core\Display\VariantBase
  12. * @see plugin_api
  13. */
  14. class VariantManager extends DefaultPluginManager {
  15. /**
  16. * Constructs a new VariantManager.
  17. *
  18. * @param \Traversable $namespaces
  19. * An object that implements \Traversable which contains the root paths
  20. * keyed by the corresponding namespace to look for plugin implementations.
  21. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
  22. * Cache backend instance to use.
  23. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
  24. * The module handler to invoke the alter hook with.
  25. */
  26. public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
  27. parent::__construct('Plugin/DisplayVariant', $namespaces, $module_handler, 'Drupal\Core\Display\VariantInterface', 'Drupal\Core\Display\Annotation\DisplayVariant');
  28. $this->setCacheBackend($cache_backend, 'variant_plugins');
  29. $this->alterInfo('display_variant_plugin');
  30. }
  31. }