JobAbortForm.php in Translation Management Tool 8
File
src/Form/JobAbortForm.php
View source
<?php
namespace Drupal\tmgmt\Form;
use Drupal\Core\Entity\ContentEntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
class JobAbortForm extends ContentEntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Abort this job?', array(
'%title' => $this->entity
->label(),
));
}
public function getDescription() {
return $this
->t('This will send a request to the translator to abort the job. After the action the job translation process will be aborted and only remaining action will be resubmitting it.');
}
public function getCancelUrl() {
return $this->entity
->toUrl();
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$entity = $this->entity;
if ($entity
->abortTranslation()) {
$entity
->addMessage('The user ordered aborting the Job through the UI.');
}
tmgmt_write_request_messages($entity);
$form_state
->setRedirectUrl($this->entity
->toUrl());
}
}