function ActionForm::submitForm

Overrides ExpressionFormInterface::submitForm

1 call to ActionForm::submitForm()
ActionForm::validateForm in src/Form/Expression/ActionForm.php
Form validation callback to validate expression elements.

File

src/Form/Expression/ActionForm.php, line 153

Class

ActionForm
UI form for adding/editing a Rules action.

Namespace

Drupal\rules\Form\Expression

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $action_id = $form_state->get('action_id');
    // Nothing to do as long as the first step is not completed.
    if (!$action_id) {
        return;
    }
    $action_definition = $this->actionManager
        ->getDefinition($action_id);
    $context_config = $this->getContextConfigFromFormValues($form_state, $action_definition['context_definitions']);
    // Rename provided variables, if any.
    if ($provided_variables = $form_state->getValue('provides')) {
        foreach ($provided_variables as $provides_name => $provides_context) {
            // Do this only on rename.
            if ($provides_name !== $provides_context['name']) {
                \Drupal::messenger()->addWarning("providing '" . $provides_name . "' as '" . $provides_context['name'] . "'");
                $context_config->provideAs($provides_name, $provides_context['name']);
            }
        }
    }
    $configuration = $context_config->toArray();
    $configuration['action_id'] = $action_id;
    $this->actionExpression
        ->setConfiguration($configuration);
}