You are here

public function EntityDisplayModeFormBase::exists in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php \Drupal\field_ui\Form\EntityDisplayModeFormBase::exists()

Determines if the display mode already exists.

Parameters

string|int $entity_id: The entity ID.

array $element: The form element.

Return value

bool TRUE if the display mode exists, FALSE otherwise.

File

core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php, line 65

Class

EntityDisplayModeFormBase
Provides the generic base class for entity display mode forms.

Namespace

Drupal\field_ui\Form

Code

public function exists($entity_id, array $element) {

  // Do not allow to add internal 'default' view mode.
  if ($entity_id == 'default') {
    return TRUE;
  }
  return (bool) $this->entityTypeManager
    ->getStorage($this->entity
    ->getEntityTypeId())
    ->getQuery()
    ->condition('id', $element['#field_prefix'] . $entity_id)
    ->execute();
}