You are here

public function PoolDeleteForm::validateForm in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x src/Form/PoolDeleteForm.php \Drupal\cms_content_sync\Form\PoolDeleteForm::validateForm()
  2. 2.0.x src/Form/PoolDeleteForm.php \Drupal\cms_content_sync\Form\PoolDeleteForm::validateForm()

Form validation handler.

Parameters

array $form: An associative array containing the structure of the form.

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

Overrides FormBase::validateForm

File

src/Form/PoolDeleteForm.php, line 20

Class

PoolDeleteForm
Builds the form to delete an Pool.

Namespace

Drupal\cms_content_sync\Form

Code

public function validateForm(array &$form, FormStateInterface $form_state) {
  $flows = [];
  foreach (Flow::getAll(false) as $flow) {
    if ($flow
      ->usesPool($this->entity)) {
      $flows[] = $flow->name;
    }
  }
  if (count($flows)) {
    $form_state
      ->setError($form, t('You can\'t delete a pool that is used in a Flow. Please remove it from the following Flows first: %flows', [
      '%flows' => implode(' ', $flows),
    ]));
  }
  return parent::validateForm($form, $form_state);
}