You are here

function show_title_is_in_display_mode in Show title 2.0.x

Same name and namespace in other branches
  1. 8 show_title.module \show_title_is_in_display_mode()

Check if the extra field is used.

Return value

bool Is used.

1 call to show_title_is_in_display_mode()
show_title_block in ./show_title.module
Define if the block title need to show.

File

./show_title.module, line 158
Module Show Title.

Code

function show_title_is_in_display_mode() {
  $entities = [];
  foreach (\Drupal::routeMatch()
    ->getParameters() as $param) {
    if ($param instanceof EntityInterface) {
      $entities[] = $param;
    }
  }
  if (!empty($entities)) {
    $entity = $entities[0];
    $display = \Drupal::entityTypeManager()
      ->getStorage('entity_view_display')
      ->load($entity
      ->getEntityTypeId() . '.' . $entity
      ->bundle() . '.default');
    if (!empty($display)) {
      $content = $display
        ->get('content');
      if (!empty($content['show_title'])) {
        return TRUE;
      }
    }
  }
  return FALSE;
}