You are here

public function TeamForm::exists in Apigee Edge 8

Checks if a team already exists with the same name.

Parameters

string $name: Team name.

array $element: Form element.

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

Return value

bool TRUE if the team exists, else FALSE.

File

modules/apigee_edge_teams/src/Entity/Form/TeamForm.php, line 149

Class

TeamForm
General form handler for the team create/edit forms.

Namespace

Drupal\apigee_edge_teams\Entity\Form

Code

public function exists(string $name, array $element, FormStateInterface $form_state) : bool {
  if ($name === '') {
    return FALSE;
  }
  $query = $this->entityTypeManager
    ->getStorage('team')
    ->getQuery()
    ->condition('name', $name);
  return (bool) $query
    ->count()
    ->execute();
}