You are here

public function ContainerForm::containerExists in GoogleTagManager 8

Checks if a container machine name is taken.

Parameters

string $value: The machine name.

array $element: An array containing the structure of the 'id' element.

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

Return value

bool Whether or not the container machine name is taken.

File

src/Form/ContainerForm.php, line 328

Class

ContainerForm
Defines the Google tag manager container settings form.

Namespace

Drupal\google_tag\Form

Code

public function containerExists($value, array $element, FormStateInterface $form_state) {

  /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $container */
  $container = $form_state
    ->getFormObject()
    ->getEntity();
  return (bool) $this->entityTypeManager
    ->getStorage($container
    ->getEntityTypeId())
    ->getQuery()
    ->condition($container
    ->getEntityType()
    ->getKey('id'), $value)
    ->execute();
}