YamlFormSubmissionDeleteForm.php in YAML Form 8
File
src/Form/YamlFormSubmissionDeleteForm.php
View source
<?php
namespace Drupal\yamlform\Form;
use Drupal\Core\Entity\ContentEntityDeleteForm;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\yamlform\YamlFormRequestInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class YamlFormSubmissionDeleteForm extends ContentEntityDeleteForm {
protected $yamlform;
protected $yamlformSubmission;
protected $sourceEntity;
protected $requestHandler;
public function __construct(EntityManagerInterface $entity_manager, YamlFormRequestInterface $request_handler) {
parent::__construct($entity_manager);
$this->requestHandler = $request_handler;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('entity.manager'), $container
->get('yamlform.request'));
}
public function buildForm(array $form, FormStateInterface $form_state) {
list($this->yamlformSubmission, $this->sourceEntity) = $this->requestHandler
->getYamlFormSubmissionEntities();
$this->yamlform = $this->yamlformSubmission
->getYamlForm();
return parent::buildForm($form, $form_state);
}
public function getQuestion() {
return $this
->t('Are you sure you want to delete @title?', [
'@title' => $this->yamlformSubmission
->label(),
]);
}
protected function getDeletionMessage() {
return $this
->t('@title has been deleted.', [
'@title' => $this->yamlformSubmission
->label(),
]);
}
public function getCancelUrl() {
$route_name = $this->requestHandler
->getRouteName($this->yamlform, $this->sourceEntity, 'yamlform.results_submissions');
$route_parameters = $this->requestHandler
->getRouteParameters($this->yamlform, $this->sourceEntity);
return new Url($route_name, $route_parameters);
}
protected function getRedirectUrl() {
return $this
->getCancelUrl();
}
protected function logDeletionMessage() {
}
}