You are here

public function AuthorPaneFormBase::exists in Author Pane 8.3

Checks for an existing AuthorPane.

Parameters

string|int $entity_id: The entity ID.

array $element: The form element.

FormStateInterface $form_state: The form state.

Return value

bool TRUE if this AuthorPane already exists, FALSE otherwise.

File

src/Form/AuthorPaneFormBase.php, line 113
Contains \Drupal\author_pane\Form\AuthorPaneFormBase.

Class

AuthorPaneFormBase
Class AuthorPaneFormBase.

Namespace

Drupal\author_pane\Form

Code

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

  // Use the query factory to build a new robot entity query.
  $query = $this->entityQueryFactory
    ->get('author_pane');

  // 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;
}