MediaViewMode.php in Media Migration 8
File
src/Plugin/migrate/source/d7/MediaViewMode.php
View source
<?php
namespace Drupal\media_migration\Plugin\migrate\source\d7;
class MediaViewMode extends DummyDrupalSqlBaseWithCountCompatibility {
protected function initializeIterator() {
$rows = [
[
'mode' => 'full',
'label' => $this
->getMediaViewModeLabel('full'),
],
[
'mode' => 'preview',
'label' => $this
->getMediaViewModeLabel('preview'),
],
[
'mode' => 'rss',
'label' => $this
->getMediaViewModeLabel('rss'),
],
[
'mode' => 'teaser',
'label' => $this
->getMediaViewModeLabel('teaser'),
],
];
if ($this
->moduleExists('search')) {
$rows[] = [
'mode' => 'search_index',
'label' => $this
->getMediaViewModeLabel('search_index'),
];
$rows[] = [
'mode' => 'search_result',
'label' => $this
->getMediaViewModeLabel('search_result'),
];
}
if ($this
->moduleExists('media_wysiwyg')) {
$rows[] = [
'mode' => 'wysiwyg',
'label' => $this
->getMediaViewModeLabel('wysiwyg'),
];
}
return new \ArrayIterator($rows);
}
public function fields() {
return [
'mode' => $this
->t('The media view mode name.'),
];
}
public function getIds() {
return [
'mode' => [
'type' => 'string',
'alias' => 'mvm',
],
];
}
protected function getMediaViewModeLabel(string $view_mode_id) {
$view_mode_storage = $this->entityTypeManager
->getStorage('entity_view_mode');
$view_mode = $view_mode_storage
->load("media.{$view_mode_id}");
return $view_mode ? $view_mode
->label() : NULL;
}
}
Classes
Name |
Description |
MediaViewMode |
Drupal 7 media view mode source based on source database. |