1 entity.module entity_view_mode_delete($entity_type, $machine_name)

Delete a custom display mode.

Parameters

string $entity_type: The entity type of the display mode to be deleted, such as "node", "comment", "user", or "taxonomy_term".

string $machine_name: Machine name of display mode.

File

core/modules/entity/entity.module, line 134
Entity API for handling entities like nodes or users.

Code

function entity_view_mode_delete($entity_type, $machine_name) {
  if ($view_mode = entity_view_mode_load($entity_type, $machine_name)) {
    module_invoke_all('entity_view_mode_delete', $view_mode, $entity_type);

    $config = config('entity.view_modes');
    $view_modes = $config->get('view_modes');
    unset($view_modes[$entity_type][$machine_name]);
    $config->set('view_modes', $view_modes);
    $config->save();

    // Clear the static entity info cache and rebuild the menu.
    entity_info_cache_clear();
    state_set('menu_rebuild_needed', TRUE);
  }
}