NumberPatternResetSequenceForm.php in Commerce Core 8.2
File
modules/number_pattern/src/Form/NumberPatternResetSequenceForm.php
View source
<?php
namespace Drupal\commerce_number_pattern\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
class NumberPatternResetSequenceForm extends EntityConfirmFormBase {
public function getQuestion() {
return $this
->t('Are you sure you want to reset the sequence for the %label number pattern?', [
'%label' => $this->entity
->label(),
]);
}
public function getConfirmText() {
return $this
->t('Reset sequence');
}
public function getCancelUrl() {
return $this->entity
->toUrl('collection');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$number_pattern = $this->entity;
$number_pattern_plugin = $number_pattern
->getPlugin();
$number_pattern_plugin
->resetSequence();
$number_pattern
->save();
$this
->messenger()
->addMessage($this
->t('The sequence for the %label number pattern has been reset.', [
'%label' => $number_pattern
->label(),
]));
$form_state
->setRedirectUrl($number_pattern
->toUrl('collection'));
}
}