function civicrm_entity_entity_view_display_alter in CiviCRM Entity 8.3
Implements hook_entity_view_display_alter().
There is no way to handle this in the entity type's view builder.
File
- ./
civicrm_entity.module, line 210 - Module file for the CiviCRM Entity module.
Code
function civicrm_entity_entity_view_display_alter(EntityViewDisplayInterface $display, array $context) {
$entity_type = \Drupal::entityTypeManager()
->getDefinition($context['entity_type']);
assert($entity_type !== NULL);
if ($entity_type
->get('civicrm_entity') && $entity_type
->hasKey('bundle')) {
$entity_display_repository = \Drupal::service('entity_display.repository');
assert($entity_display_repository instanceof EntityDisplayRepositoryInterface);
$root_display = $entity_display_repository
->getViewDisplay($entity_type
->id(), $entity_type
->id());
$display
->set('content', $root_display
->get('content'));
$display
->set('hidden', $root_display
->get('hidden'));
if ($root_display instanceof LayoutBuilderEntityViewDisplay) {
$layout_builder_settings = $root_display
->getThirdPartySettings('layout_builder');
foreach ($layout_builder_settings as $setting_key => $setting) {
$display
->setThirdPartySetting('layout_builder', $setting_key, $setting);
}
}
}
}