/**
* Rebuild displays for single Entity Type.
*
* @param string $entity_type_id
* The entity type machine name.
* @param string $bundle
* The bundle we need to rebuild.
*/
public function rebuildEntityTypeDisplays($entity_type_id,
$bundle) { // Get the displays.
$view_modes =
$this->entityDisplayRepository->
getViewModeOptions($entity_type_id);
$form_modes =
$this->entityDisplayRepository->
getFormModeOptions($entity_type_id);
// Save view mode displays.
$view_mode_ids =
array_map(function D
$view_mode) use ($entity_type_id,
$bundle) { return "
$entity_type_id.
$bundle.
$view_mode";
},
array_keys($view_modes));
foreach ($this->entityTypeManager->
getStorage('entity_view_display'
)->
loadMultiple($view_mode_ids) as $display) { $display->
save();
} // Save form mode displays.
$form_mode_ids =
array_map(function D
$form_mode) use ($entity_type_id,
$bundle) { return "
$entity_type_id.
$bundle.
$form_mode";
},