diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php
index a557063..d79af40 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php
@@ -7,28 +7,16 @@
namespace Drupal\taxonomy\Form;
-use Drupal\Core\Form\FormInterface;
-use Drupal\Core\Controller\ControllerInterface;
-use Drupal\Core\Entity\EntityManager;
+use Drupal\Core\Form\FormBase;
use Drupal\Core\Config\ConfigFactory;
-use Drupal\Core\Database\Connection;
use Drupal\Core\Extension\ModuleHandlerInterface;
-use Drupal\Core\StringTranslation\TranslationManager;
use Drupal\taxonomy\VocabularyInterface;
-use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerInterface;
/*
* Provides terms overview form for a taxonomy vocabulary.
*/
-class OverviewTerms implements ControllerInterface, FormInterface {
-
- /**
- * Entity Manager.
- *
- * @var \Drupal\Core\Entity\EntityManager
- */
- protected $entityManager;
+class OverviewTerms extends FormBase {
/**
* Taxonomy config.
@@ -38,20 +26,6 @@ class OverviewTerms implements ControllerInterface, FormInterface {
protected $config;
/**
- * Current database connection.
- *
- * @var \Drupal\Core\Database\Connection
- */
- protected $database;
-
- /**
- * Current request.
- *
- * @var \Symfony\Component\HttpFoundation\Request
- */
- protected $request;
-
- /**
* The module handler service.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
@@ -59,35 +33,16 @@ class OverviewTerms implements ControllerInterface, FormInterface {
protected $moduleHandler;
/**
- * The translation manager service.
- *
- * @var \Drupal\Core\StringTranslation\TranslationManager
- */
- protected $translation;
-
- /**
* Constructs an OverviewTerms object.
*
- * @param \Drupal\Core\Entity\EntityManager $entity_manager
- * The entity manager service.
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The config factory service.
- * @param \Drupal\Core\Database\Connection $connection
- * The current database connection.
- * @param \Symfony\Component\HttpFoundation\Request $request
- * The current request.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler service.
- * @param \Drupal\Core\StringTranslation\TranslationManager $translation
- * The translation manager.
*/
- public function __construct(EntityManager $entity_manager, ConfigFactory $config_factory, Connection $connection, Request $request, ModuleHandlerInterface $module_handler, TranslationManager $translation) {
- $this->entityManager = $entity_manager;
+ public function __construct(ConfigFactory $config_factory, ModuleHandlerInterface $module_handler) {
$this->config = $config_factory->get('taxonomy.settings');
- $this->database = $connection;
- $this->request = $request;
$this->moduleHandler = $module_handler;
- $this->translation = $translation;
}
/**
@@ -95,12 +50,8 @@ public function __construct(EntityManager $entity_manager, ConfigFactory $config
*/
public static function create(ContainerInterface $container) {
return new static(
- $container->get('plugin.manager.entity'),
$container->get('config.factory'),
- $container->get('database'),
- $container->get('request'),
- $container->get('module_handler'),
- $container->get('string_translation')
+ $container->get('module_handler')
);
}
@@ -134,7 +85,7 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $
$form_state['taxonomy']['vocabulary'] = $taxonomy_vocabulary;
$parent_fields = FALSE;
- ($page = $this->request->query->get('page')) ?: 0;
+ $page = $this->getRequest()->query->get('page') ?: 0;
// Number of terms per page.
$page_increment = $this->config->get('terms_per_page_admin');
// Elements shown on this page.
@@ -253,8 +204,8 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $
// Build the actual form.
$form['terms'] = array(
'#type' => 'table',
- '#header' => array($this->translation->translate('Name'), $this->translation->translate('Weight'), $this->translation->translate('Operations')),
- '#empty' => $this->translation->translate('No terms available. Add term.', array('@link' => url('admin/structure/taxonomy/manage/' . $taxonomy_vocabulary->id() . '/add'))),
+ '#header' => array($this->t('Name'), $this->t('Weight'), $this->t('Operations')),
+ '#empty' => $this->t('No terms available. Add term.', array('@link' => url('admin/structure/taxonomy/manage/' . $taxonomy_vocabulary->id() . '/add'))),
'#attributes' => array(
'id' => 'taxonomy',
),
@@ -308,7 +259,7 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $
'#type' => 'weight',
'#delta' => $delta,
'#title_display' => 'invisible',
- '#title' => $this->translation->translate('Weight for added term'),
+ '#title' => $this->t('Weight for added term'),
'#default_value' => $term->weight->value,
'#attributes' => array(
'class' => array('term-weight'),
@@ -316,19 +267,19 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $
);
$operations = array(
'edit' => array(
- 'title' => $this->translation->translate('edit'),
+ 'title' => $this->t('edit'),
'href' => $edit_uri['path'],
'query' => $destination,
),
'delete' => array(
- 'title' => $this->translation->translate('delete'),
+ 'title' => $this->t('delete'),
'href' => $uri['path'] . '/delete',
'query' => $destination,
),
);
- if ($this->moduleHandler->invoke('content_translation', 'translate_access', array($term))) {
+ if ($this->moduleHandler->moduleExists('content_translation') && content_translation_translate_access($term)) {
$operations['translate'] = array(
- 'title' => $this->translation->translate('translate'),
+ 'title' => $this->t('translate'),
'href' => $uri['path'] . '/translations',
'query' => $destination,
);
@@ -395,12 +346,13 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $
$form['actions'] = array('#type' => 'actions', '#tree' => FALSE);
$form['actions']['submit'] = array(
'#type' => 'submit',
- '#value' => $this->translation->translate('Save'),
+ '#value' => $this->t('Save'),
'#button_type' => 'primary',
);
$form['actions']['reset_alphabetical'] = array(
'#type' => 'submit',
- '#value' => $this->translation->translate('Reset to alphabetical')
+ '#submit' => array(array($this, 'submitReset')),
+ '#value' => $this->t('Reset to alphabetical'),
);
$form_state['redirect'] = array(current_path(), ($page ? array('query' => array('page' => $page)) : array()));
}
@@ -409,11 +361,6 @@ public function buildForm(array $form, array &$form_state, VocabularyInterface $
}
/**
- * {@inheritdoc}
- */
- public function validateForm(array &$form, array &$form_state) {}
-
- /**
* Form submission handler.
*
* Rather than using a textfield or weight field, this form depends entirely
@@ -510,7 +457,14 @@ public function submitForm(array &$form, array &$form_state) {
$vocabulary->hierarchy = $hierarchy;
$vocabulary->save();
}
- drupal_set_message($this->translation->translate('The configuration options have been saved.'));
+ drupal_set_message($this->t('The configuration options have been saved.'));
+ }
+
+ /**
+ * Redirects to confirmation form for the reset action.
+ */
+ public function submitReset(array &$form, array &$form_state) {
+ $form_state['redirect'] = 'admin/structure/taxonomy/manage/' . $form_state['taxonomy']['vocabulary']->id() . '/reset';
}
}