You are here

public function FieldInheritanceForm::exists in Field Inheritance 8

Same name and namespace in other branches
  1. 2.0.x src/Form/FieldInheritanceForm.php \Drupal\field_inheritance\Form\FieldInheritanceForm::exists()

Determines if the field inheritance 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

src/Form/FieldInheritanceForm.php, line 526

Class

FieldInheritanceForm
Provides a form for managing field inheritance entities.

Namespace

Drupal\field_inheritance\Form

Code

public function exists($entity_id, array $element) {
  if (!empty($this->entity->destination_entity_type) && !empty($this->entity->destination_entity_bundle)) {
    $id = $this->entity->destination_entity_type . '_' . $this->entity->destination_entity_bundle . '_' . $entity_id;
    $return = (bool) $this->entityTypeManager
      ->getStorage($this->entity
      ->getEntityTypeId())
      ->getQuery()
      ->condition('id', $id)
      ->execute();
    return $return;
  }
}