3 namespace Drupal\embed\EmbedType;
5 use Drupal\Core\Cache\CacheBackendInterface;
6 use Drupal\Core\Extension\ModuleHandlerInterface;
7 use Drupal\Core\Plugin\DefaultPluginManager;
10 * Provides an Embed type plugin manager.
12 * @see \Drupal\embed\Annotation\EmbedType
13 * @see \Drupal\embed\EmbedType\EmbedTypeInterface
14 * @see hook_embed_type_plugins_alter()
16 class EmbedTypeManager extends DefaultPluginManager {
19 * Constructs a EmbedTypeManager object.
21 * @param \Traversable $namespaces
22 * An object that implements \Traversable which contains the root paths
23 * keyed by the corresponding namespace to look for plugin implementations.
24 * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
25 * Cache backend instance to use.
26 * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
27 * The module handler to invoke the alter hook with.
29 public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
30 parent::__construct('Plugin/EmbedType', $namespaces, $module_handler, 'Drupal\embed\EmbedType\EmbedTypeInterface', 'Drupal\embed\Annotation\EmbedType');
31 $this->alterInfo('embed_type_plugins');
32 $this->setCacheBackend($cache_backend, 'embed_type_plugins');
36 * Provides a list of plugins suitable for form options.
39 * An array of valid plugin labels, keyed by plugin ID.
41 public function getDefinitionOptions() {
42 $options = array_map(function ($definition) {
43 return (string) $definition['label'];
44 }, $this->getDefinitions());