diff --git a/core/modules/forum/lib/Drupal/forum/Form/ContainerFormController.php b/core/modules/forum/lib/Drupal/forum/Form/ContainerFormController.php index a40c83b..208d39c 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/ContainerFormController.php +++ b/core/modules/forum/lib/Drupal/forum/Form/ContainerFormController.php @@ -28,12 +28,12 @@ public function form(array $form, array &$form_state) { $form = parent::form($form, $form_state, $taxonomy_term); // Set the title and description of the name field. - $form['name']['#title'] = t('Container name'); - $form['name']['#description'] = t('Short but meaningful name for this collection of related forums.'); + $form['name']['#title'] = $this->t('Container name'); + $form['name']['#description'] = $this->t('Short but meaningful name for this collection of related forums.'); // Alternate description for the container parent. - $form['parent'][0]['#description'] = t('Containers are usually placed at the top (root) level, but may also be placed inside another container or forum.'); - $this->forumFormType = t('forum container'); + $form['parent'][0]['#description'] = $this->t('Containers are usually placed at the top (root) level, but may also be placed inside another container or forum.'); + $this->forumFormType = $this->t('forum container'); return $form; } @@ -45,9 +45,10 @@ public function save(array $form, array &$form_state) { $term = parent::save($form, $form_state); if ($is_new) { // Update config item to track the container terms. - $containers = $this->config->get('containers'); + $config = $this->configFactory->get('forum.settings'); + $containers = $config->get('containers'); $containers[] = $term->id(); - $this->config->set('containers', $containers)->save(); + $config->set('containers', $containers)->save(); } } diff --git a/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php b/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php index 5cfba76..299366c 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php +++ b/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php @@ -8,7 +8,7 @@ namespace Drupal\forum\Form; use Drupal\Core\Form\ConfirmFormBase; -use Drupal\taxonomy\Entity\Term; +use Drupal\taxonomy\TermInterface; /** * Builds the form to delete a forum term. @@ -18,7 +18,7 @@ class DeleteForm extends ConfirmFormBase { /** * The taxonomy term being deleted. * - * @var \Drupal\taxonomy\Entity\Term + * @var \Drupal\taxonomy\TermInterface */ protected $taxonomyTerm; @@ -33,7 +33,7 @@ public function getFormID() { * {@inheritdoc} */ public function getQuestion() { - return t('Are you sure you want to delete the forum %label?', array('%label' => $this->taxonomyTerm->label())); + return $this->t('Are you sure you want to delete the forum %label?', array('%label' => $this->taxonomyTerm->label())); } /** @@ -47,13 +47,13 @@ public function getCancelPath() { * {@inheritdoc} */ public function getConfirmText() { - return t('Delete'); + return $this->t('Delete'); } /** * {@inheritdoc} */ - public function buildForm(array $form, array &$form_state, Term $taxonomy_term = NULL) { + public function buildForm(array $form, array &$form_state, TermInterface $taxonomy_term = NULL) { $this->taxonomyTerm = $taxonomy_term; return parent::buildForm($form, $form_state); @@ -64,7 +64,7 @@ public function buildForm(array $form, array &$form_state, Term $taxonomy_term = */ public function submitForm(array &$form, array &$form_state) { $this->taxonomyTerm->delete(); - drupal_set_message(t('The forum %label and all sub-forums have been deleted.', array('%label' => $this->taxonomyTerm->label()))); + drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', array('%label' => $this->taxonomyTerm->label()))); watchdog('forum', 'forum: deleted %label and all its sub-forums.', array('%label' => $this->taxonomyTerm->label()), WATCHDOG_NOTICE); $form_state['redirect'] = 'admin/structure/forum'; } diff --git a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php index ee5aa37..fc4b52c 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php +++ b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php @@ -11,8 +11,8 @@ use Drupal\Core\Config\ConfigFactory; use Drupal\taxonomy\TermFormController; use Drupal\taxonomy\TermStorageControllerInterface; +use Drupal\taxonomy\VocabularyStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\Request; /** * Base form controller for forum term edit forms. @@ -41,43 +41,36 @@ class ForumFormController extends TermFormController { protected $config; /** - * The current request. - * - * @var \Symfony\Component\HttpFoundation\Request - */ - protected $request; - - /** * Term Storage Controller. * * @var \Drupal\taxonomy\TermStorageControllerInterface */ - protected $storageController; + protected $termStorage; /** * Constructs a new ForumFormController object. * + * @param \Drupal\taxonomy\VocabularyStorageControllerInterface $vocab_storage + * The vocabulary storage. * @param \Drupal\Core\Config\ConfigFactory $config_factory * The config factory service. - * @param \Symfony\Component\HttpFoundation\Request $request - * The current request. - * @param \Drupal\taxonomy\TermStorageControllerInterface $storage_controller - * The storage controller. + * @param \Drupal\taxonomy\TermStorageControllerInterface $term_storage + * The term storage. */ - public function __construct(ConfigFactory $config_factory, Request $request, TermStorageControllerInterface $storage_controller) { - $this->config = $config_factory->get('forum.settings'); - $this->request = $request; - $this->storageController = $storage_controller; + public function __construct(VocabularyStorageControllerInterface $vocab_storage, ConfigFactory $config_factory, TermStorageControllerInterface $term_storage) { + parent::__construct($vocab_storage, $config_factory); + $this->termStorage = $term_storage; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { + $entity_manager = $container->get('plugin.manager.entity'); return new static( + $entity_manager->getStorageController('taxonomy_vocabulary'), $container->get('config.factory'), - $container->get('request'), - $container->get('plugin.manager.entity')->getStorageController('taxonomy_term') + $entity_manager->getStorageController('taxonomy_term') ); } @@ -90,11 +83,11 @@ public function form(array $form, array &$form_state) { $form = parent::form($form, $form_state, $taxonomy_term); // Set the title and description of the name field. - $form['name']['#title'] = t('Forum name'); - $form['name']['#description'] = t('Short but meaningful name for this collection of threaded discussions.'); + $form['name']['#title'] = $this->t('Forum name'); + $form['name']['#description'] = $this->t('Short but meaningful name for this collection of threaded discussions.'); // Change the description. - $form['description']['#description'] = t('Description and guidelines for discussions within this forum.'); + $form['description']['#description'] = $this->t('Description and guidelines for discussions within this forum.'); // Re-use the weight field. $form['weight'] = $form['relations']['weight']; @@ -104,10 +97,10 @@ public function form(array $form, array &$form_state) { // Our parent field is different to the taxonomy term. $form['parent']['#tree'] = TRUE; - $form['parent'][0] = $this->forumParentSelect($taxonomy_term->id(), t('Parent')); + $form['parent'][0] = $this->forumParentSelect($taxonomy_term->id(), $this->t('Parent')); $form['#theme'] = 'forum_form'; - $this->forumFormType = t('forum'); + $this->forumFormType = $this->t('forum'); return $form; } @@ -129,17 +122,17 @@ public function buildEntity(array $form, array &$form_state) { public function save(array $form, array &$form_state) { $term = $this->entity; - $status = $this->storageController->save($term); + $status = $this->termStorage->save($term); switch ($status) { case SAVED_NEW: - drupal_set_message(t('Created new @type %term.', array('%term' => $term->label(), '@type' => $this->forumFormType))); - watchdog('forum', 'Created new @type %term.', array('%term' => $term->label(), '@type' => $this->forumFormType), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id())); + drupal_set_message($this->t('Created new @type %term.', array('%term' => $term->label(), '@type' => $this->forumFormType))); + watchdog('forum', 'Created new @type %term.', array('%term' => $term->label(), '@type' => $this->forumFormType), WATCHDOG_NOTICE, l($this->t('edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id())); $form_state['values']['tid'] = $term->id(); break; case SAVED_UPDATED: - drupal_set_message(t('The @type %term has been updated.', array('%term' => $term->label(), '@type' => $this->forumFormType))); - watchdog('taxonomy', 'Updated @type %term.', array('%term' => $term->label(), '@type' => $this->forumFormType), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id())); + drupal_set_message($this->t('The @type %term has been updated.', array('%term' => $term->label(), '@type' => $this->forumFormType))); + watchdog('taxonomy', 'Updated @type %term.', array('%term' => $term->label(), '@type' => $this->forumFormType), WATCHDOG_NOTICE, l($this->t('edit'), 'admin/structure/forum/edit/' . $this->urlStub . '/' . $term->id())); // Clear the page and block caches to avoid stale data. Cache::invalidateTags(array('content' => TRUE)); break; @@ -154,9 +147,10 @@ public function save(array $form, array &$form_state) { */ public function delete(array $form, array &$form_state) { $destination = array(); - if ($this->request->query->get('destination')) { + $request = $this->getRequest(); + if ($request->query->has('destination')) { $destination = drupal_get_destination(); - $this->request->query->remove('destination'); + $request->query->remove('destination'); } $term = $this->getEntity($form_state); $form_state['redirect'] = array( @@ -187,7 +181,7 @@ protected function forumParentSelect($tid, $title) { $parent = 0; } - $vid = $this->config->get('vocabulary'); + $vid = $this->configFactory->get('forum.settings')->get('vocabulary'); // @todo Inject a taxonomy service when one exists. $children = taxonomy_get_tree($vid, $tid, NULL, TRUE); @@ -199,7 +193,7 @@ protected function forumParentSelect($tid, $title) { // @todo Inject a taxonomy service when one exists. $tree = taxonomy_get_tree($vid, 0, NULL, TRUE); - $options[0] = '<' . t('root') . '>'; + $options[0] = '<' . $this->t('root') . '>'; if ($tree) { foreach ($tree as $term) { if (!in_array($term->id(), $exclude)) { @@ -208,7 +202,7 @@ protected function forumParentSelect($tid, $title) { } } - $description = t('Forums may be placed at the top (root) level, or inside another container or forum.'); + $description = $this->t('Forums may be placed at the top (root) level, or inside another container or forum.'); return array( '#type' => 'select', diff --git a/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php b/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php index 9e8590f..42f8280 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php +++ b/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.php @@ -15,14 +15,14 @@ class ForumSettingsForm extends SystemConfigFormBase { /** - * Implements \Drupal\Core\Form\FormInterface::getFormID(). + * {@inheritdoc} */ public function getFormID() { return 'forum_admin_settings'; } /** - * Implements \Drupal\Core\Form\FormInterface::buildForm(). + * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { $config = $this->configFactory->get('forum.settings'); @@ -30,38 +30,38 @@ public function buildForm(array $form, array &$form_state) { $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500)); $form['forum_hot_topic'] = array( '#type' => 'select', - '#title' => t('Hot topic threshold'), + '#title' => $this->t('Hot topic threshold'), '#default_value' => $config->get('topics.hot_threshold'), '#options' => $number, - '#description' => t('The number of replies a topic must have to be considered "hot".'), + '#description' => $this->t('The number of replies a topic must have to be considered "hot".'), ); $number = drupal_map_assoc(array(10, 25, 50, 75, 100)); $form['forum_per_page'] = array( '#type' => 'select', - '#title' => t('Topics per page'), + '#title' => $this->t('Topics per page'), '#default_value' => $config->get('topics.page_limit'), '#options' => $number, - '#description' => t('Default number of forum topics displayed per page.'), + '#description' => $this->t('Default number of forum topics displayed per page.'), ); $forder = array( - 1 => t('Date - newest first'), - 2 => t('Date - oldest first'), - 3 => t('Posts - most active first'), - 4 => t('Posts - least active first') + 1 => $this->t('Date - newest first'), + 2 => $this->t('Date - oldest first'), + 3 => $this->t('Posts - most active first'), + 4 => $this->t('Posts - least active first') ); $form['forum_order'] = array( '#type' => 'radios', - '#title' => t('Default order'), + '#title' => $this->t('Default order'), '#default_value' => $config->get('topics.order'), '#options' => $forder, - '#description' => t('Default display order for topics.'), + '#description' => $this->t('Default display order for topics.'), ); return parent::buildForm($form, $form_state); } /** - * Implements \Drupal\Core\Form\FormInterface::submitForm(). + * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { $this->configFactory->get('forum.settings')