function panelizer_quickedit_entity_view_alter in Panelizer 8.5
Same name and namespace in other branches
- 8.3 panelizer_quickedit/panelizer_quickedit.module \panelizer_quickedit_entity_view_alter()
- 8.4 panelizer_quickedit/panelizer_quickedit.module \panelizer_quickedit_entity_view_alter()
Implements hook_entity_view_alter().
File
- panelizer_quickedit/
panelizer_quickedit.module, line 39
Code
function panelizer_quickedit_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
// Explicitly add support for ctools_block by attaching a custom view-mode to
// every Block that's about to be rendered.
if (isset($build['#panels_display'])) {
// We only support known Display Builders.
$supported_plugins = [
'ipe',
'standard',
];
if (in_array($build['#panels_display']
->getBuilder()
->getPluginId(), $supported_plugins)) {
$region_names = Element::getVisibleChildren($build['content']);
foreach ($region_names as $region_name) {
$block_ids = Element::getVisibleChildren($build['content'][$region_name]);
foreach ($block_ids as $block_id) {
$block =& $build['content'][$region_name][$block_id];
if (isset($block['#base_plugin_id']) && $block['#base_plugin_id'] === 'entity_field') {
$view_mode = 'panelizer-' . $build['#view_mode'] . '-block-id-' . $block_id;
$block['content']['field']['#view_mode'] = $view_mode;
}
}
}
}
}
}