You are here

public function ConditionDelete::submitForm in Chaos Tool Suite (ctools) 8.3

Form submission 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 FormInterface::submitForm

File

src/Form/ConditionDelete.php, line 89

Class

ConditionDelete

Namespace

Drupal\ctools\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $cached_values = $this->tempstore
    ->get($this->tempstore_id)
    ->get($this->machine_name);
  $conditions = $this
    ->getConditions($cached_values);

  /** @var  $instance \Drupal\ctools\ConstraintConditionInterface */
  $instance = $this->manager
    ->createInstance($conditions[$this->id]['id'], $conditions[$this->id]);
  if ($instance instanceof ConstraintConditionInterface) {
    $instance
      ->removeConstraints($this
      ->getContexts($cached_values));
  }
  unset($conditions[$this->id]);
  $cached_values = $this
    ->setConditions($cached_values, $conditions);
  $this->tempstore
    ->get($this->tempstore_id)
    ->set($this->machine_name, $cached_values);
  list($route_name, $route_parameters) = $this
    ->getParentRouteInfo($cached_values);
  $form_state
    ->setRedirect($route_name, $route_parameters);
}