You are here

public function MediaThumbnailManager::__construct in Media Thumbnails 8

Constructs a new MediaThumbnailManager object.

Parameters

\Traversable $namespaces: An object that implements \Traversable which contains the root paths keyed by the corresponding namespace to look for plugin implementations.

\Drupal\Core\Cache\CacheBackendInterface $cache_backend: Cache backend instance to use.

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler to invoke the alter hook with.

Overrides DefaultPluginManager::__construct

File

src/Plugin/MediaThumbnailManager.php, line 45

Class

MediaThumbnailManager
Provides the Media thumbnail plugin manager.

Namespace

Drupal\media_thumbnails\Plugin

Code

public function __construct(Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
  parent::__construct('Plugin/MediaThumbnail', $namespaces, $module_handler, MediaThumbnailInterface::class, MediaThumbnail::class);
  $this
    ->alterInfo('media_thumbnails_media_thumbnail_info');
  $this
    ->setCacheBackend($cache_backend, 'media_thumbnails_media_thumbnail_plugins');
  $this->plugins = [];

  // Build a list of unique mime types supported by thumbnail plugins.
  $definitions = $this
    ->getDefinitions();
  foreach ($definitions as $id => $definition) {
    foreach ($definition['mime'] as $mime) {
      $this->plugins[$mime] = $id;
    }
  }
}