protected function ImgTagToEmbedFilter::createEmbedNode in Media Migration 8
Creates a DOM element representing an embed media on the destination.
Parameters
\DOMDocument $dom: The \DOMDocument in which the embed \DOMElement is being created.
string|int $file_id: The ID of the file which should be represented by the new embed tag.
Return value
\DOMElement The new embed tag as a writable \DOMElement.
1 call to ImgTagToEmbedFilter::createEmbedNode()
- ImgTagToEmbedFilter::transform in src/
Plugin/ migrate/ process/ ImgTagToEmbedFilter.php - Performs the associated process.
File
- src/
Plugin/ migrate/ process/ ImgTagToEmbedFilter.php, line 317
Class
- ImgTagToEmbedFilter
- Transforms <img src="/files/cat.png"> tags to <drupal-media …>.
Namespace
Drupal\media_migration\Plugin\migrate\processCode
protected function createEmbedNode(\DOMDocument $dom, $file_id) {
$filter_destination_is_entity_embed = $this->destinationFilterPluginId === MediaMigration::MEDIA_TOKEN_DESTINATION_FILTER_ENTITY_EMBED;
$tag = $filter_destination_is_entity_embed ? 'drupal-entity' : 'drupal-media';
$display_mode_attribute = $filter_destination_is_entity_embed ? 'data-entity-embed-display' : 'data-view-mode';
$embed_node = $dom
->createElement($tag);
$embed_node
->setAttribute('data-entity-type', 'media');
if (MediaMigration::getEmbedMediaReferenceMethod() === MediaMigration::EMBED_MEDIA_REFERENCE_METHOD_ID) {
$embed_node
->setAttribute('data-entity-id', $file_id);
}
else {
$embed_node
->setAttribute('data-entity-uuid', $this->mediaUuidOracle
->getMediaUuid((int) $file_id));
}
$embed_node
->setAttribute($display_mode_attribute, 'default');
if ($filter_destination_is_entity_embed) {
$embed_node
->setAttribute('data-embed-button', 'media');
}
$embed_node
->setAttribute($display_mode_attribute, $this
->getDisplayPluginId('default', $this->destinationFilterPluginId));
return $embed_node;
}