diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index aa93ba6..2ee7d78 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -212,9 +212,9 @@ function forum_menu_local_tasks_alter(&$data, $router_item, $root_path) { } /** - * Implements hook_entity_info_alter(). + * Implements hook_entity_info(). */ -function forum_entity_info_alter(&$info) { +function forum_entity_info(&$info) { // Register forum specific form controllers. $info['taxonomy_term']['controllers']['form']['forum'] = 'Drupal\forum\ForumFormController'; $info['taxonomy_term']['controllers']['form']['container'] = 'Drupal\forum\ContainerFormController'; diff --git a/core/modules/forum/lib/Drupal/forum/ForumController.php b/core/modules/forum/lib/Drupal/forum/ForumController.php index 670cca9..00ebbf0 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumController.php +++ b/core/modules/forum/lib/Drupal/forum/ForumController.php @@ -7,10 +7,11 @@ namespace Drupal\forum; -use Drupal\Core\ControllerInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\ConfigFactory; +use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Entity\EntityManager; +use Drupal\taxonomy\TermStorageControllerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Controller routines for forum routes. @@ -32,10 +33,21 @@ class ForumController implements ControllerInterface { protected $config; /** + * Term storage controller. + * + * @var \Drupal\taxonomy\TermStorageControllerInterface + */ + protected $storageController; + + /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { - return new static($container->get('plugin.manager.entity'), $container->get('config.factory')); + return new static( + $container->get('plugin.manager.entity'), + $container->get('config.factory'), + $container->get('plugin.manager.entity')->getStorageController('taxonomy_term') + ); } /** @@ -45,10 +57,13 @@ public static function create(ContainerInterface $container) { * The entity manager service. * @param \Drupal\Core\Config\ConfigFactory $config_factory * The factory for configuration objects. + * @param \Drupal\taxonomy\TermStorageControllerInterface $storage_controller + * The term storage controller. */ - public function __construct(EntityManager $entity_manager, ConfigFactory $config_factory) { + public function __construct(EntityManager $entity_manager, ConfigFactory $config_factory, TermStorageControllerInterface $storage_controller) { $this->entityManager = $entity_manager; $this->config = $config_factory->get('forum.settings'); + $this->storageController = $storage_controller; } /** @@ -59,12 +74,10 @@ public function __construct(EntityManager $entity_manager, ConfigFactory $config */ public function addForum() { $vid = $this->config->get('vocabulary'); - $taxonomy_term = $this->entityManager->getStorageController('taxonomy_term')->create(array( + $taxonomy_term = $this->storageController->create(array( 'vid' => $vid, )); - // @todo use $this->entityManager->getform() when - // http://drupal.org/node/1982980 is in. - return entity_get_form($taxonomy_term, 'forum'); + return $this->entityManager->getForm($taxonomy_term, 'forum'); } /** @@ -75,12 +88,10 @@ public function addForum() { */ public function addContainer() { $vid = $this->config->get('vocabulary'); - $taxonomy_term = $this->entityManager->getStorageController('taxonomy_term')->create(array( + $taxonomy_term = $this->storageController->create(array( 'vid' => $vid, )); - // @todo use $this->entityManager->getform() when - // http://drupal.org/node/1982980 is in. - return entity_get_form($taxonomy_term, 'container'); + return $this->entityManager->getForm($taxonomy_term, 'container'); } } diff --git a/core/modules/forum/lib/Drupal/forum/ForumFormController.php b/core/modules/forum/lib/Drupal/forum/ForumFormController.php index 9480f8a..253efc1 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumFormController.php +++ b/core/modules/forum/lib/Drupal/forum/ForumFormController.php @@ -224,4 +224,5 @@ protected function forumParentSelect($tid, $title) { '#required' => TRUE ); } + }