function AddExpressionForm::buildForm

Overrides EditExpressionForm::buildForm

File

src/Form/AddExpressionForm.php, line 49

Class

AddExpressionForm
UI form to add an expression like a condition or action to a rule.

Namespace

Drupal\rules\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, RulesUiHandlerInterface $rules_ui_handler = NULL, $uuid = NULL, $expression_id = NULL) {
    $this->expressionId = $expression_id;
    $this->uuid = $uuid;
    // When initially adding the expression, we have to initialize the object
    // and add the expression.
    if (!$this->uuid) {
        // Before we add our edited expression to the component's expression,
        // we clone it such that we do not change the source component until
        // the form has been successfully submitted.
        $component = clone $rules_ui_handler->getComponent();
        $this->uuid = $this->getEditedExpression($component)
            ->getUuid();
        $form_state->set('component', $component);
        $form_state->set('uuid', $this->uuid);
    }
    return parent::buildForm($form, $form_state, $rules_ui_handler, $this->uuid);
}