abstract class EmbedFilterBase in Media Migration 8
Base class for media embed code filter text process plugins.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\migrate\ProcessPluginBase implements MigrateProcessInterface
- class \Drupal\media_migration\Plugin\migrate\process\EmbedFilterBase implements ContainerFactoryPluginInterface
- class \Drupal\migrate\ProcessPluginBase implements MigrateProcessInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of EmbedFilterBase
File
- src/
Plugin/ migrate/ process/ EmbedFilterBase.php, line 14
Namespace
Drupal\media_migration\Plugin\migrate\processView source
abstract class EmbedFilterBase extends ProcessPluginBase implements ContainerFactoryPluginInterface {
/**
* The actual migration plugin instance.
*
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* The media UUID oracle.
*
* @var \Drupal\media_migration\MediaMigrationUuidOracleInterface
*/
protected $mediaUuidOracle;
/**
* The entity embed display plugin manager service, if available.
*
* @var \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager|null
*/
protected $entityEmbedDisplayPluginManager;
/**
* Constructs a new EmbedFilterBase object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
* The migration entity.
* @param \Drupal\media_migration\MediaMigrationUuidOracleInterface $media_uuid_oracle
* The media UUID oracle.
* @param \Drupal\entity_embed\EntityEmbedDisplay\EntityEmbedDisplayManager|null $entity_embed_display_manager
* The entity embed display plugin manager service, if available.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MediaMigrationUuidOracleInterface $media_uuid_oracle, $entity_embed_display_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->migration = $migration;
$this->mediaUuidOracle = $media_uuid_oracle;
$this->entityEmbedDisplayPluginManager = $entity_embed_display_manager;
}
/**
* Returns the destination display plugin ID.
*
* @param string $view_mode
* The view_mode from the source.
* @param string $destination_filter_plugin_id
* The transform destination filter plugin ID.
*
* @return string
* The embed media's display plugin ID or view_mode.
*/
protected function getDisplayPluginId(string $view_mode, string $destination_filter_plugin_id) {
switch ($destination_filter_plugin_id) {
case 'entity_embed':
$display_plugin_id = "view_mode:media.{$view_mode}";
break;
case 'media_embed':
return $view_mode;
default:
throw new \LogicException();
}
// Ensure that the display plugin exists.
if ($this->entityEmbedDisplayPluginManager instanceof EntityEmbedDisplayManager) {
$available_plugins = $this->entityEmbedDisplayPluginManager
->getDefinitionOptionsForEntityType('media');
if (empty($available_plugins)) {
throw new \LogicException("Media Migration cannot replace a media_filter token in a content entity, since there aren't any available entity_embed display plugins.");
}
if (!isset($available_plugins[$display_plugin_id])) {
// If the preselected display plugin does not exist, then we will
// try to map it to 'view_mode:media.full'.
if (isset($available_plugins['view_mode:media.full'])) {
$display_plugin_id = 'view_mode:media.full';
}
else {
$view_mode_plugins = array_reduce(array_keys($available_plugins), function ($carry, $plugin_id) {
if (strpos($plugin_id, 'view_mode:media.') === 0) {
$carry[$plugin_id] = $plugin_id;
}
return $carry;
});
// If we have 'view_mode:media.[any]', we use the first one; if
// not, then use the first display plugin.
$display_plugin_id = !empty($view_mode_plugins) ? reset($view_mode_plugins) : array_keys($available_plugins)[0];
}
}
}
return $display_plugin_id;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ContainerFactoryPluginInterface:: |
public static | function | Creates an instance of the plugin. | 112 |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
EmbedFilterBase:: |
protected | property | The entity embed display plugin manager service, if available. | |
EmbedFilterBase:: |
protected | property | The media UUID oracle. | |
EmbedFilterBase:: |
protected | property | The actual migration plugin instance. | |
EmbedFilterBase:: |
protected | function | Returns the destination display plugin ID. | |
EmbedFilterBase:: |
public | function |
Constructs a new EmbedFilterBase object. Overrides PluginBase:: |
2 |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
ProcessPluginBase:: |
public | function |
Indicates whether the returned value requires multiple handling. Overrides MigrateProcessInterface:: |
3 |
ProcessPluginBase:: |
public | function |
Performs the associated process. Overrides MigrateProcessInterface:: |
70 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |