function EntityDisplayModeFormBase::exists
Same name in other branches
- 9 core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php \Drupal\field_ui\Form\EntityDisplayModeFormBase::exists()
- 10 core/modules/field_ui/src/Form/EntityDisplayModeFormBase.php \Drupal\field_ui\Form\EntityDisplayModeFormBase::exists()
- 11.x 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\FormCode
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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.