/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $component = $this->rulesUiHandler->getComponent(); $component->getExpression()->deleteExpression($this->uuid); $this->rulesUiHandler->updateComponent($component); $form_state->setRedirectUrl($this->getCancelUrl()); }
/** * {@inheritdoc} */ 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); }
/** * Gets the form handler for the component's expression. * * @return \Drupal\rules\Form\Expression\ExpressionFormInterface|null * The form handling object if there is one, NULL otherwise. */ protected function getFormHandler() { return $this->rulesUiHandler->getComponent()->getExpression()->getFormHandler(); }
/** * Provides the page title on the form. */ public function getTitle(RulesUiHandlerInterface $rules_ui_handler, $uuid) { $this->uuid = $uuid; $expression = $this->getEditedExpression($rules_ui_handler->getComponent()); return $this->t('Edit @expression', ['@expression' => $expression->getLabel()]); }