You are here

public function EditExpressionForm::buildForm in Rules 8.3

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides FormInterface::buildForm

1 call to EditExpressionForm::buildForm()
AddExpressionForm::buildForm in src/Form/AddExpressionForm.php
Form constructor.
1 method overrides EditExpressionForm::buildForm()
AddExpressionForm::buildForm in src/Form/AddExpressionForm.php
Form constructor.

File

src/Form/EditExpressionForm.php, line 54

Class

EditExpressionForm
UI form to edit an expression like a condition or action in a rule.

Namespace

Drupal\rules\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, RulesUiHandlerInterface $rules_ui_handler = NULL, $uuid = NULL) {
  $this->rulesUiHandler = $rules_ui_handler;
  $this->component = is_object($form_state
    ->get('component')) ? $form_state
    ->get('component') : $this->rulesUiHandler
    ->getComponent();
  $this->uuid = $form_state
    ->get('uuid') ?: $uuid;

  // During form rebuilds, keep track of changes using form state.
  $form_state
    ->set('rules_ui_handler', $this->rulesUiHandler);
  $form_state
    ->set('component', $this->component);
  $form_state
    ->set('uuid', $this->uuid);
  $expression = $this
    ->getEditedExpression($this->component);
  if (!$expression) {
    throw new NotFoundHttpException();
  }
  $form_handler = $expression
    ->getFormHandler();
  $form = $form_handler
    ->form($form, $form_state);
  return $form;
}