PaymentMethodConfigurationDeleteForm.php in Payment 8.2
File
src/Entity/PaymentMethodConfiguration/PaymentMethodConfigurationDeleteForm.php
View source
<?php
namespace Drupal\payment\Entity\PaymentMethodConfiguration;
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 PaymentMethodConfigurationDeleteForm 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('payment.logger'));
}
public function getQuestion() {
return $this
->t('Do you really want to delete %label?', array(
'%label' => $this
->getEntity()
->label(),
));
}
public function getCancelUrl() {
return $this
->getEntity()
->toUrl('collection');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->getEntity()
->delete();
$this->logger
->info('Payment method configuration %label (@id) has been deleted.', [
'@id' => $this
->getEntity()
->id(),
'%label' => $this
->getEntity()
->label(),
]);
$this
->messenger()
->addMessage($this
->t('%label has been deleted.', [
'%label' => $this
->getEntity()
->label(),
]));
$form_state
->setRedirectUrl($this
->getEntity()
->toUrl('collection'));
}
public function getConfirmText() {
return $this
->t('Delete');
}
}