function ConditionDelete::submitForm

Same name in other branches
  1. 4.0.x src/Form/ConditionDelete.php \Drupal\ctools\Form\ConditionDelete::submitForm()

Overrides FormInterface::submitForm

File

src/Form/ConditionDelete.php, line 98

Class

ConditionDelete
Delete Condition Confirmation Form.

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  \Drupal\ctools\ConstraintConditionInterface $instance */
    $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);
    [
        $route_name,
        $route_parameters,
    ] = $this->getParentRouteInfo($cached_values);
    $form_state->setRedirect($route_name, $route_parameters);
}