termStorage = $term_storage; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('entity.manager')->getStorage('taxonomy_term') ); } /** * {@inheritdoc} */ public function getFormId() { return 'taxonomy_vocabulary_confirm_reset_alphabetical'; } /** * {@inheritdoc} */ public function getQuestion() { return $this->t('Are you sure you want to reset the vocabulary %title to alphabetical order?', ['%title' => $this->entity->label()]); } /** * {@inheritdoc} */ public function getCancelUrl() { return $this->entity->urlInfo('overview-form'); } /** * {@inheritdoc} */ public function getDescription() { return $this->t('Resetting a vocabulary will discard all custom ordering and sort items alphabetically.'); } /** * {@inheritdoc} */ public function getConfirmText() { return $this->t('Reset to alphabetical'); } /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { parent::submitForm($form, $form_state); $this->termStorage->resetWeights($this->entity->id()); $this->messenger()->addStatus($this->t('Reset vocabulary %name to alphabetical order.', ['%name' => $this->entity->label()])); $this->logger('taxonomy')->notice('Reset vocabulary %name to alphabetical order.', ['%name' => $this->entity->label()]); $form_state->setRedirectUrl($this->getCancelUrl()); } }