protected function EmbedFilterBase::getDisplayPluginId in Media Migration 8
Returns the destination display plugin ID.
Parameters
string $view_mode: The view_mode from the source.
string $destination_filter_plugin_id: The transform destination filter plugin ID.
Return value
string The embed media's display plugin ID or view_mode.
2 calls to EmbedFilterBase::getDisplayPluginId()
- ImgTagToEmbedFilter::createEmbedNode in src/
Plugin/ migrate/ process/ ImgTagToEmbedFilter.php - Creates a DOM element representing an embed media on the destination.
- MediaWysiwygFilter::getEmbedCode in src/
Plugin/ migrate/ process/ MediaWysiwygFilter.php - Creates the replacement token for the specified embed filter.
File
- src/
Plugin/ migrate/ process/ EmbedFilterBase.php, line 72
Class
- EmbedFilterBase
- Base class for media embed code filter text process plugins.
Namespace
Drupal\media_migration\Plugin\migrate\processCode
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;
}