JobItemAbortForm.php in Translation Management Tool 8
File
src/Form/JobItemAbortForm.php
View source
<?php
namespace Drupal\tmgmt\Form;
use Drupal\Core\Entity\ContentEntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\tmgmt\TMGMTException;
class JobItemAbortForm extends ContentEntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to abort the job item %title?', array(
'%title' => $this->entity
->label(),
));
}
public function getDescription() {
return $this
->t('Aborted job items can no longer be accepted. The provider will not be notified.');
}
public function getCancelUrl() {
return $this->entity
->toUrl();
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$entity = $this->entity;
try {
if (!$entity
->abortTranslation()) {
tmgmt_write_request_messages($entity);
}
} catch (TMGMTException $e) {
$this
->messenger()
->addError(t('Job item cannot be aborted: %error.', array(
'%error' => $e
->getMessage(),
)));
}
$form_state
->setRedirectUrl($this->entity
->toUrl());
}
}