/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { /** @var \Drupal\tmgmt\Entity\Job $entity */ $entity = $this->entity; if (!$entity->abortTranslation()) { // This is the case when a translator does not support the abort // operation. // It would make more sense to not display the button for the action, // however we do not know if the translator is able to abort a job until // we trigger the action. foreach ($entity->getMessagesSince() as $message) { /** @var \Drupal\tmgmt\MessageInterface $message */ if ($message->getType() == 'debug') { continue; } if ($text = $message->getMessage()) { // We want to persist also the type therefore we will set the // messages directly and not return them. drupal_set_message($text, $message->getType()); } } } else { $entity->addMessage('The user ordered aborting the Job through the UI.'); } tmgmt_write_request_messages($entity); $form_state->setRedirectUrl($this->entity->toUrl()); }
/** * Ajax callback for the job item review form. */ function ajaxReviewForm(array $form, FormStateInterface $form_state) { $key = array_slice($form_state->getTriggeringElement()['#array_parents'], 0, 2); $render_data = NestedArray::getValue($form, $key); tmgmt_write_request_messages($form_state->getFormObject()->getEntity()->getJob()); return $render_data; }