core/modules/media/media.api.php | 10 ++++---- core/modules/media/media.services.yml | 4 +-- .../{MediaHandler.php => MediaStorageProxy.php} | 29 +++++++++++----------- core/modules/media/src/Entity/MediaType.php | 2 +- ...iaHandlerBase.php => MediaStorageProxyBase.php} | 4 +-- ...nterface.php => MediaStorageProxyInterface.php} | 8 +++--- ...lerManager.php => MediaStorageProxyManager.php} | 14 +++++------ core/modules/media/src/MediaTypeForm.php | 22 ++++++++-------- core/modules/media/src/MediaTypeInterface.php | 4 +-- core/modules/media/src/SourceFieldInterface.php | 2 +- .../{media/Handler => MediaStorageProxy}/Test.php | 14 +++++------ .../FunctionalJavascript/MediaTypeCreationTest.php | 2 +- 12 files changed, 58 insertions(+), 57 deletions(-) diff --git a/core/modules/media/media.api.php b/core/modules/media/media.api.php index 48ffe5d..7ecf6a3 100644 --- a/core/modules/media/media.api.php +++ b/core/modules/media/media.api.php @@ -11,13 +11,13 @@ */ /** - * Alters the information provided in \Drupal\media\Annotation\MediaHandler. + * Alters the information provided in \Drupal\media\Annotation\MediaStorageProxy. * - * @param array $handlers - * The array of media handler plugin definitions, keyed by plugin ID. + * @param array $definitions + * The array of media storage proxy plugin definitions, keyed by plugin ID. */ -function hook_media_handler_info_alter(array &$handlers) { - $handlers['youtube']['label'] = t('Youtube rocks!'); +function hook_media_storage_proxies_alter(array &$definitions) { + $definitions['youtube']['label'] = t('Youtube rocks!'); } /** diff --git a/core/modules/media/media.services.yml b/core/modules/media/media.services.yml index 730e2d8..6c6acde 100644 --- a/core/modules/media/media.services.yml +++ b/core/modules/media/media.services.yml @@ -1,6 +1,6 @@ services: - plugin.manager.media.handler: - class: Drupal\media\MediaHandlerManager + plugin.manager.media.storage_proxy: + class: Drupal\media\MediaStorageProxyManager parent: default_plugin_manager media.thumbnail_handler: diff --git a/core/modules/media/src/Annotation/MediaHandler.php b/core/modules/media/src/Annotation/MediaStorageProxy.php similarity index 37% rename from core/modules/media/src/Annotation/MediaHandler.php rename to core/modules/media/src/Annotation/MediaStorageProxy.php index 6286a73..ef831a2 100644 --- a/core/modules/media/src/Annotation/MediaHandler.php +++ b/core/modules/media/src/Annotation/MediaStorageProxy.php @@ -5,25 +5,26 @@ use Drupal\Component\Annotation\Plugin; /** - * Defines a media handler plugin annotation object. + * Defines a media storage proxy plugin annotation object. * - * Media handlers are responsible for implementing all the logic for dealing - * with a particular type of media. They provide various universal and - * type-specific metadata about media of the type they handle. + * Media storage proxies are responsible for implementing all the logic for + * proxying a particular media storage (both local and remote) into Drupal. They + * have handlers covering the various aspects of interacting with media: a + * metadata handler, a thumbnail handler, and so on. * - * Plugin namespace: Plugin\media\Handler + * Plugin namespace: Plugin\MediaStorageProxy * - * For a working example, see \Drupal\media\Plugin\media\Handler\File. + * For a working example, see \Drupal\media\Plugin\MediaStorageProxy\File. * - * @see \Drupal\media\MediaHandlerInterface - * @see \Drupal\media\MediaHandlerBase - * @see \Drupal\media\MediaHandlerManager - * @see hook_media_handler_info_alter() + * @see \Drupal\media\MediaStorageProxyInterface + * @see \Drupal\media\MediaStorageProxyBase + * @see \Drupal\media\MediaStorageProxyManager + * @see hook_media_storage_proxies_alter() * @see plugin_api * * @Annotation */ -class MediaHandler extends Plugin { +class MediaStorageProxy extends Plugin { /** * The plugin ID. @@ -33,7 +34,7 @@ class MediaHandler extends Plugin { public $id; /** - * The human-readable name of the media handler. + * The human-readable name of the media storage proxy. * * @var \Drupal\Core\Annotation\Translation * @@ -42,7 +43,7 @@ class MediaHandler extends Plugin { public $label; /** - * A brief description of the media handler. + * A brief description of the media storage proxy. * * @var \Drupal\Core\Annotation\Translation * @@ -51,7 +52,7 @@ class MediaHandler extends Plugin { public $description = ''; /** - * The field types that can be used as a source field for this media handler. + * Field types that can be used as source field for this media storage proxy. * * @var string[] */ diff --git a/core/modules/media/src/Entity/MediaType.php b/core/modules/media/src/Entity/MediaType.php index aca44b1..abab0d1 100644 --- a/core/modules/media/src/Entity/MediaType.php +++ b/core/modules/media/src/Entity/MediaType.php @@ -195,7 +195,7 @@ public function getHandler() { */ protected function handlerPluginCollection() { if (!$this->handlerPluginCollection) { - $this->handlerPluginCollection = new DefaultSingleLazyPluginCollection(\Drupal::service('plugin.manager.media.handler'), $this->handler, $this->handler_configuration); + $this->handlerPluginCollection = new DefaultSingleLazyPluginCollection(\Drupal::service('plugin.manager.media.storage_proxy'), $this->handler, $this->handler_configuration); } return $this->handlerPluginCollection; } diff --git a/core/modules/media/src/MediaHandlerBase.php b/core/modules/media/src/MediaStorageProxyBase.php similarity index 98% rename from core/modules/media/src/MediaHandlerBase.php rename to core/modules/media/src/MediaStorageProxyBase.php index a52a1f1..1b92e8f 100644 --- a/core/modules/media/src/MediaHandlerBase.php +++ b/core/modules/media/src/MediaStorageProxyBase.php @@ -13,9 +13,9 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Base implementation of media handler plugin. + * Base implementation of media storage proxy plugin. */ -abstract class MediaHandlerBase extends PluginBase implements SourceFieldInterface, ContainerFactoryPluginInterface { +abstract class MediaStorageProxyBase extends PluginBase implements SourceFieldInterface, ContainerFactoryPluginInterface { /** * Plugin label. diff --git a/core/modules/media/src/MediaHandlerInterface.php b/core/modules/media/src/MediaStorageProxyInterface.php similarity index 95% rename from core/modules/media/src/MediaHandlerInterface.php rename to core/modules/media/src/MediaStorageProxyInterface.php index a910221..3685cba 100644 --- a/core/modules/media/src/MediaHandlerInterface.php +++ b/core/modules/media/src/MediaStorageProxyInterface.php @@ -53,13 +53,13 @@ * exposes can be automatically mapped to the fields on the media entity. * Handler will be able to define how this is done. * - * @see \Drupal\media\Annotation\MediaHandler - * @see \Drupal\media\MediaHandlerBase - * @see \Drupal\media\MediaHandlerManager + * @see \Drupal\media\Annotation\MediaStorageProxy + * @see \Drupal\media\MediaStorageProxyBase + * @see \Drupal\media\MediaStorageProxyManager * @see \Drupal\media\MediaTypeInterface * @see plugin_api */ -interface MediaHandlerInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface { +interface MediaStorageProxyInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface { /** * Gets list of fields provided by this plugin. diff --git a/core/modules/media/src/MediaHandlerManager.php b/core/modules/media/src/MediaStorageProxyManager.php similarity index 61% rename from core/modules/media/src/MediaHandlerManager.php rename to core/modules/media/src/MediaStorageProxyManager.php index 045cf03..dfefdb3 100644 --- a/core/modules/media/src/MediaHandlerManager.php +++ b/core/modules/media/src/MediaStorageProxyManager.php @@ -5,15 +5,15 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\DefaultPluginManager; -use Drupal\media\Annotation\MediaHandler; +use Drupal\media\Annotation\MediaStorageProxy; /** - * Manages media handler plugins. + * Manages media storage proxy plugins. */ -class MediaHandlerManager extends DefaultPluginManager { +class MediaStorageProxyManager extends DefaultPluginManager { /** - * Constructs a new MediaHandlerManager. + * Constructs a new MediaStorageProxyManager. * * @param \Traversable $namespaces * An object that implements \Traversable which contains the root paths @@ -24,10 +24,10 @@ class MediaHandlerManager extends DefaultPluginManager { * The module handler. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { - parent::__construct('Plugin/media/Handler', $namespaces, $module_handler, MediaHandlerInterface::class, MediaHandler::class); + parent::__construct('Plugin/MediaStorageProxy', $namespaces, $module_handler, MediaStorageProxyInterface::class, MediaStorageProxy::class); - $this->alterInfo('media_handler_info'); - $this->setCacheBackend($cache_backend, 'media_handler_plugins'); + $this->alterInfo('media_storage_proxy'); + $this->setCacheBackend($cache_backend, 'media_storage_proxy_plugins'); } } diff --git a/core/modules/media/src/MediaTypeForm.php b/core/modules/media/src/MediaTypeForm.php index 9210e96..11c019a 100644 --- a/core/modules/media/src/MediaTypeForm.php +++ b/core/modules/media/src/MediaTypeForm.php @@ -19,11 +19,11 @@ class MediaTypeForm extends EntityForm { /** - * Media handler plugin manager. + * Media storage proxy plugin manager. * - * @var \Drupal\media\MediaHandlerManager + * @var \Drupal\media\MediaStorageProxyManager */ - protected $handlerManager; + protected $mediaStorageProxyManager; /** * Entity field manager service. @@ -35,13 +35,13 @@ class MediaTypeForm extends EntityForm { /** * Constructs a new class instance. * - * @param \Drupal\media\MediaHandlerManager $handler_manager - * Media handler plugin manager. + * @param \Drupal\media\MediaStorageProxyManager $media_storage_proxy_manager + * Media storage proxy plugin manager. * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager * Entity field manager service. */ - public function __construct(MediaHandlerManager $handler_manager, EntityFieldManagerInterface $entity_field_manager) { - $this->handlerManager = $handler_manager; + public function __construct(MediaStorageProxyManager $media_storage_proxy_manager, EntityFieldManagerInterface $entity_field_manager) { + $this->mediaStorageProxyManager = $media_storage_proxy_manager; $this->entityFieldManager = $entity_field_manager; } @@ -50,7 +50,7 @@ public function __construct(MediaHandlerManager $handler_manager, EntityFieldMan */ public static function create(ContainerInterface $container) { return new static( - $container->get('plugin.manager.media.handler'), + $container->get('plugin.manager.media.storage_proxy'), $container->get('entity_field.manager') ); } @@ -70,8 +70,8 @@ public function ajaxHandlerData(array $form, FormStateInterface $form_state) { public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); - // Handler is not set when the entity is initially created. - /** @var \Drupal\media\MediaHandlerInterface $handler */ + // Media storage proxy is not set when the entity is initially created. + /** @var \Drupal\media\MediaStorageProxyInterface $handler */ $handler = $this->entity->get('handler') ? $this->entity->getHandler() : NULL; if ($this->operation === 'add') { @@ -105,7 +105,7 @@ public function form(array $form, FormStateInterface $form_state) { '#description' => $this->t('Describe this media type. The text will be displayed on the Add new media page.'), ]; - $plugins = $this->handlerManager->getDefinitions(); + $plugins = $this->mediaStorageProxyManager->getDefinitions(); $options = []; foreach ($plugins as $plugin_id => $definition) { $options[$plugin_id] = $definition['label']; diff --git a/core/modules/media/src/MediaTypeInterface.php b/core/modules/media/src/MediaTypeInterface.php index 071440b..5f7f0c1 100644 --- a/core/modules/media/src/MediaTypeInterface.php +++ b/core/modules/media/src/MediaTypeInterface.php @@ -28,7 +28,7 @@ * "Invoices", "Subtitles", "Meeting notes", etc. They are all files stored on * some kind of storage, but their meaning is different. * - * @see \Drupal\media\MediaHandlerInterface + * @see \Drupal\media\MediaStorageProxyInterface */ interface MediaTypeInterface extends ConfigEntityInterface, EntityDescriptionInterface, RevisionableEntityBundleInterface { @@ -54,7 +54,7 @@ public function setQueueThumbnailDownloadsStatus($queue_thumbnail_downloads); /** * Returns the media handler. * - * @return \Drupal\media\MediaHandlerInterface + * @return \Drupal\media\MediaStorageProxyInterface * The media handler. */ public function getHandler(); diff --git a/core/modules/media/src/SourceFieldInterface.php b/core/modules/media/src/SourceFieldInterface.php index 73f184b..5c5b27b 100644 --- a/core/modules/media/src/SourceFieldInterface.php +++ b/core/modules/media/src/SourceFieldInterface.php @@ -5,7 +5,7 @@ /** * Interface for media handler plugins that depend on a field. */ -interface SourceFieldInterface extends MediaHandlerInterface { +interface SourceFieldInterface extends MediaStorageProxyInterface { /** * Returns the source field for a media type using this media handler. diff --git a/core/modules/media/tests/modules/media_test_handler/src/Plugin/media/Handler/Test.php b/core/modules/media/tests/modules/media_test_handler/src/Plugin/MediaStorageProxy/Test.php similarity index 79% rename from core/modules/media/tests/modules/media_test_handler/src/Plugin/media/Handler/Test.php rename to core/modules/media/tests/modules/media_test_handler/src/Plugin/MediaStorageProxy/Test.php index 7bdf5bb..5756a3b 100644 --- a/core/modules/media/tests/modules/media_test_handler/src/Plugin/media/Handler/Test.php +++ b/core/modules/media/tests/modules/media_test_handler/src/Plugin/MediaStorageProxy/Test.php @@ -1,22 +1,22 @@ drupalGet("admin/structure/media/manage/{$mediaTypeMachineName}"); - $this->assertSession()->pageTextContains('Test handler field is used to store the essential information about the media item.'); + $this->assertSession()->pageTextContains('Test media storage proxy field is used to store the essential information about the media item.'); } /**