You are here

public function SlideGroupBaseForm::exists in Drupal Slider 8

Same name and namespace in other branches
  1. 8.2 src/Form/SlideGroupBaseForm.php \Drupal\drupal_slider\Form\SlideGroupBaseForm::exists()

Checks for an existing Slide group.

File

src/Form/SlideGroupBaseForm.php, line 96

Class

SlideGroupBaseForm
Class SlideGroupBaseForm.

Namespace

Drupal\drupal_slider\Form

Code

public function exists($entity_id, array $element, FormStateInterface $form_state) {
  $query = $this->entityStorage
    ->getQuery();

  // Query the entity ID to see if its in use.
  $result = $query
    ->condition('id', $element['#field_prefix'] . $entity_id)
    ->execute();

  // We don't need to return the ID, only if it exists or not.
  return (bool) $result;
}