PatternEnableForm.php in Pathauto 8
File
src/Form/PatternEnableForm.php
View source
<?php
namespace Drupal\pathauto\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class PatternEnableForm extends EntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to enable the pattern %label?', [
'%label' => $this->entity
->label(),
]);
}
public function getCancelUrl() {
return new Url('entity.pathauto_pattern.collection');
}
public function getConfirmText() {
return $this
->t('Enable');
}
public function getDescription() {
return '';
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity
->enable()
->save();
$this
->messenger()
->addMessage($this
->t('Enabled pattern %label.', [
'%label' => $this->entity
->label(),
]));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}