You are here

public function ConfigTestForm::exists in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/tests/config_test/src/ConfigTestForm.php \Drupal\config_test\ConfigTestForm::exists()

Determines if the entity already exists.

Parameters

string|int $entity_id: The entity ID.

array $element: The form element.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

bool TRUE if the entity exists, FALSE otherwise.

File

core/modules/config/tests/config_test/src/ConfigTestForm.php, line 194
Contains \Drupal\config_test\ConfigTestForm.

Class

ConfigTestForm
Form controller for the test config edit forms.

Namespace

Drupal\config_test

Code

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

  /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
  $entity = $form_state
    ->getFormObject()
    ->getEntity();
  return (bool) $this->entityQuery
    ->get($entity
    ->getEntityTypeId())
    ->condition($entity
    ->getEntityType()
    ->getKey('id'), $entity_id)
    ->execute();
}