/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { // Allow the condition to submit the form. $condition_values = (new FormState())->setValues($form_state->getValue('condition')); $this->condition->submitConfigurationForm($form, $condition_values); // Update the original form values. $form_state->setValue('condition', $condition_values->getValues()); if ($this->condition instanceof ContextAwarePluginInterface) { $this->condition->setContextMapping($condition_values->getValue('context_mapping', [])); } // Set the submission message. drupal_set_message($this->submitMessageText()); $configuration = $this->condition->getConfiguration(); // If this condition is new, add it to the block_visibility_group. if (!isset($configuration['uuid'])) { $this->block_visibility_group->addCondition($configuration); } // Save the block_visibility_group entity. $this->block_visibility_group->save(); $this->setConditionRedirect($form_state); }
/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->block_visibility_group->removeCondition($this->condition->getConfiguration()['uuid']); $this->block_visibility_group->save(); drupal_set_message($this->t('The condition %name has been removed.', ['%name' => $this->condition->getPluginDefinition()['label']])); $this->setConditionRedirect($form_state); }