MollieProfileDeleteForm.php in Mollie Payment 8.2
File
src/Entity/MollieProfile/MollieProfileDeleteForm.php
View source
<?php
namespace Drupal\mollie_payment\Entity\MollieProfile;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class MollieProfileDeleteForm extends EntityConfirmFormBase {
protected $logger;
public function __construct(TranslationInterface $string_translation, LoggerInterface $logger) {
$this->logger = $logger;
$this->stringTranslation = $string_translation;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('string_translation'), $container
->get('mollie_payment.logger'));
}
public function getQuestion() {
return $this
->t('Do you really want to delete %label?', [
'%label' => $this
->getEntity()
->label(),
]);
}
public function getCancelUrl() {
return $this
->getEntity()
->toUrl('collection');
}
public function getConfirmText() {
return $this
->t('Delete');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->getEntity()
->delete();
$this->logger
->info('Mollie profile %label (@id) has been deleted.', [
'@id' => $this
->getEntity()
->id(),
'%label' => $this
->getEntity()
->label(),
]);
drupal_set_message($this
->t('%label has been deleted.', [
'%label' => $this
->getEntity()
->label(),
]));
$form_state
->setRedirectUrl($this
->getEntity()
->toUrl('collection'));
}
}