protected function ContentModelUpdater::updateViewDisplay in Panopoly 8.2
Update configuration for entity view displays.
Parameters
string $id: The view display ID.
1 call to ContentModelUpdater::updateViewDisplay()
- ContentModelUpdater::installViewDisplays in modules/
panopoly/ panopoly_media/ src/ Update/ ContentModelUpdater.php - Install view displays.
File
- modules/
panopoly/ panopoly_media/ src/ Update/ ContentModelUpdater.php, line 504
Class
- ContentModelUpdater
- Applies changes to media content model from schema versions 8204 to 8205.
Namespace
Drupal\panopoly_media\UpdateCode
protected function updateViewDisplay($id) {
$viewDisplay = EntityViewDisplay::load($id);
switch ($id) {
case 'media.panopoly_media_file.default':
$content = $viewDisplay
->get('content');
$hidden = $viewDisplay
->get('hidden');
$this
->changeNestedValue($content, 'field_media_file::label', 'hidden', 'visually_hidden');
$this
->changeNestedValue($content, 'field_media_file::weight', 1, 0);
$this
->changeNestedValue($content, 'field_panopoly_media_description', NULL, [
'label' => 'hidden',
'region' => 'content',
'settings' => [],
'third_party_settings' => [],
'type' => 'text_default',
'weight' => 1,
]);
$this
->unsetNestedValue($hidden, 'field_panopoly_media_description');
$this
->changeNestedValue($content, 'field_panopoly_media_tags', NULL, [
'label' => 'inline',
'region' => 'content',
'settings' => [
'link' => TRUE,
],
'third_party_settings' => [],
'type' => 'entity_reference_label',
'weight' => 2,
]);
$this
->unsetNestedValue($hidden, 'field_panopoly_media_tags');
$this
->unsetNestedValue($content, 'name');
$this
->setNestedValue($hidden, 'name', TRUE);
$viewDisplay
->set('content', $content);
$viewDisplay
->set('hidden', $hidden);
$viewDisplay
->save();
break;
case 'media.panopoly_media_file.teaser':
$content = $viewDisplay
->get('content');
$hidden = $viewDisplay
->get('hidden');
$this
->unsetNestedValue($content, 'field_media_file');
$this
->setNestedValue($hidden, 'field_media_file', TRUE);
$this
->unsetNestedValue($content, 'field_panopoly_media_description');
$this
->setNestedValue($hidden, 'field_panopoly_media_description', TRUE);
$this
->unsetNestedValue($content, 'field_panopoly_media_tags');
$this
->setNestedValue($hidden, 'field_panopoly_media_tags', TRUE);
$this
->changeNestedValue($content, 'name::weight', 0, 1);
$this
->changeNestedValue($content, 'name::label', 'above', 'hidden');
$this
->changeNestedValue($content, 'name::settings::link_to_entity', FALSE, TRUE);
$this
->changeNestedValue($content, 'thumbnail', NULL, [
'label' => 'hidden',
'region' => 'content',
'settings' => [
'image_link' => 'file',
'image_style' => 'medium',
],
'third_party_settings' => [],
'type' => 'image',
'weight' => 0,
]);
$this
->unsetNestedValue($hidden, 'thumbnail');
$viewDisplay
->set('content', $content);
$viewDisplay
->set('hidden', $hidden);
$viewDisplay
->save();
break;
case 'media.panopoly_media_image.default':
$content = $viewDisplay
->get('content');
$hidden = $viewDisplay
->get('hidden');
$this
->setNestedValue($hidden, 'name', TRUE);
$this
->unsetNestedValue($content, 'name');
$this
->changeNestedValue($content, 'field_media_image::settings::image_style', 'medium', '');
$this
->changeNestedValue($content, 'field_media_image::weight', 1, 0);
$this
->changeNestedValue($content, 'field_panopoly_media_description', NULL, [
'label' => 'hidden',
'region' => 'content',
'settings' => [],
'third_party_settings' => [],
'type' => 'text_default',
'weight' => 1,
]);
$this
->unsetNestedValue($hidden, 'field_panopoly_media_description');
$this
->changeNestedValue($content, 'field_panopoly_media_tags', NULL, [
'label' => 'inline',
'region' => 'content',
'settings' => [
'link' => TRUE,
],
'third_party_settings' => [],
'type' => 'entity_reference_label',
'weight' => 2,
]);
$this
->unsetNestedValue($hidden, 'field_panopoly_media_tags');
$viewDisplay
->set('content', $content);
$viewDisplay
->set('hidden', $hidden);
$viewDisplay
->save();
break;
case 'media.panopoly_media_image.embed_large':
$content = $viewDisplay
->get('content');
$hidden = $viewDisplay
->get('hidden');
$this
->changeNestedValue($content, 'field_media_image::weight', 1, 0);
$viewDisplay
->set('content', $content);
$viewDisplay
->set('hidden', $hidden);
$viewDisplay
->save();
break;
case 'media.panopoly_media_image.teaser':
$content = $viewDisplay
->get('content');
$hidden = $viewDisplay
->get('hidden');
$this
->unsetNestedValue($content, 'field_media_image');
$this
->setNestedValue($hidden, 'field_media_image', TRUE);
$this
->unsetNestedValue($content, 'field_panopoly_media_description');
$this
->setNestedValue($hidden, 'field_panopoly_media_description', TRUE);
$this
->unsetNestedValue($content, 'field_panopoly_media_tags');
$this
->setNestedValue($hidden, 'field_panopoly_media_tags', TRUE);
$this
->changeNestedValue($content, 'name::settings::link_to_entity', FALSE, TRUE);
$this
->changeNestedValue($content, 'name::weight', 0, 1);
$this
->changeNestedValue($content, 'thumbnail', NULL, [
'label' => 'hidden',
'region' => 'content',
'settings' => [
'image_link' => '',
'image_style' => 'panopoly_media_entity_browser_thumbnail',
],
'third_party_settings' => [],
'type' => 'image',
'weight' => 0,
]);
$this
->unsetNestedValue($hidden, 'thumbnail');
$viewDisplay
->set('content', $content);
$viewDisplay
->set('hidden', $hidden);
$viewDisplay
->save();
break;
case 'media.panopoly_media_remote_video.default':
$content = $viewDisplay
->get('content');
$hidden = $viewDisplay
->get('hidden');
$this
->changeNestedValue($content, 'field_panopoly_media_description', NULL, [
'label' => 'hidden',
'region' => 'content',
'settings' => [],
'third_party_settings' => [],
'type' => 'text_default',
'weight' => 1,
]);
$this
->unsetNestedValue($hidden, 'field_panopoly_media_description');
$this
->changeNestedValue($content, 'field_panopoly_media_tags', NULL, [
'label' => 'inline',
'region' => 'content',
'settings' => [
'link' => TRUE,
],
'third_party_settings' => [],
'type' => 'entity_reference_label',
'weight' => 2,
]);
$this
->unsetNestedValue($hidden, 'field_panopoly_media_tags');
$viewDisplay
->set('content', $content);
$viewDisplay
->set('hidden', $hidden);
$viewDisplay
->save();
break;
case 'media.panopoly_media_remote_video.full':
$content = $viewDisplay
->get('content');
$hidden = $viewDisplay
->get('hidden');
$this
->changeNestedValue($content, 'name::weight', -5, 0);
$viewDisplay
->set('content', $content);
$viewDisplay
->set('hidden', $hidden);
$viewDisplay
->save();
break;
case 'media.panopoly_media_remote_video.teaser':
$content = $viewDisplay
->get('content');
$hidden = $viewDisplay
->get('hidden');
$this
->changeNestedValue($content, 'name::settings::link_to_entity', FALSE, TRUE);
$this
->changeNestedValue($content, 'name::weight', -5, 1);
$this
->changeNestedValue($content, 'thumbnail', NULL, [
'label' => 'hidden',
'region' => 'content',
'settings' => [
'image_link' => '',
'image_style' => 'panopoly_media_entity_browser_thumbnail',
],
'third_party_settings' => [],
'type' => 'image',
'weight' => 0,
]);
$this
->unsetNestedValue($hidden, 'thumbnail');
$this
->unsetNestedValue($content, 'field_media_oembed_video');
$this
->setNestedValue($hidden, 'field_media_oembed_video', TRUE);
$this
->unsetNestedValue($content, 'field_panopoly_media_description');
$this
->setNestedValue($hidden, 'field_panopoly_media_description', TRUE);
$this
->unsetNestedValue($content, 'field_panopoly_media_tags');
$this
->setNestedValue($hidden, 'field_panopoly_media_tags', TRUE);
$viewDisplay
->set('content', $content);
$viewDisplay
->set('hidden', $hidden);
$viewDisplay
->save();
break;
}
}