function lightning_media_update_8018 in Lightning Media 8.4
Same name and namespace in other branches
- 8 lightning_media.install \lightning_media_update_8018()
- 8.2 lightning_media.install \lightning_media_update_8018()
- 8.3 lightning_media.install \lightning_media_update_8018()
Updates the media browser's argument validation.
File
- ./
lightning_media.install, line 288 - Contains install and update routines for Lightning Media.
Code
function lightning_media_update_8018() {
$browser = EntityBrowser::load('media_browser');
$view = View::load('media');
if (empty($browser) || empty($view)) {
return;
}
$widgets = $browser
->get('widgets');
foreach ($widgets as &$widget) {
if ($widget['id'] == 'view' && $widget['settings']['view'] == $view
->id()) {
$display =& $view
->getDisplay($widget['settings']['view_display']);
$keys = [
'display_options',
'arguments',
'bundle',
'validate',
'type',
];
if (NestedArray::getValue($display, $keys) == 'entity:media_bundle') {
NestedArray::setValue($display, $keys, 'entity:media_type');
}
$view
->save();
break;
}
}
}