commit b8d18e36e657c15e1f7ec9e1942c001c1d0d47a0 Author: Lee Rowlands Date: Mon May 27 15:57:52 2013 +1000 Patch 10 diff --git a/core/modules/forum/lib/Drupal/forum/ContainerFormController.php b/core/modules/forum/lib/Drupal/forum/ContainerFormController.php index dd3ce84..62c6af0 100644 --- a/core/modules/forum/lib/Drupal/forum/ContainerFormController.php +++ b/core/modules/forum/lib/Drupal/forum/ContainerFormController.php @@ -45,11 +45,9 @@ public function save(array $form, array &$form_state) { $term = parent::save($form, $form_state); if ($insert) { // Update config item to track the container terms. - // @todo Inject Config factory. - $config = config('forum.settings'); - $containers = $config->get('containers'); + $containers = $this->config->get('containers'); $containers[] = $term->id(); - $config->set('containers', $containers)->save(); + $this->config->set('containers', $containers)->save(); } } diff --git a/core/modules/forum/lib/Drupal/forum/ForumController.php b/core/modules/forum/lib/Drupal/forum/ForumController.php index 320692e..670cca9 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumController.php +++ b/core/modules/forum/lib/Drupal/forum/ForumController.php @@ -56,15 +56,14 @@ public function __construct(EntityManager $entity_manager, ConfigFactory $config * * @return array * Render array for the add form. - * - * @todo remove and use _entity_form and _values when - * http://drupal.org/node/1978166 is in. */ public function addForum() { $vid = $this->config->get('vocabulary'); $taxonomy_term = $this->entityManager->getStorageController('taxonomy_term')->create(array( 'vid' => $vid, )); + // @todo use $this->entityManager->getform() when + // http://drupal.org/node/1982980 is in. return entity_get_form($taxonomy_term, 'forum'); } @@ -73,15 +72,14 @@ public function addForum() { * * @return array * Render array for the add form. - * - * @todo remove and use _entity_form and _values when - * http://drupal.org/node/1978166 is in. */ public function addContainer() { $vid = $this->config->get('vocabulary'); $taxonomy_term = $this->entityManager->getStorageController('taxonomy_term')->create(array( 'vid' => $vid, )); + // @todo use $this->entityManager->getform() when + // http://drupal.org/node/1982980 is in. return entity_get_form($taxonomy_term, 'container'); } diff --git a/core/modules/forum/lib/Drupal/forum/ForumFormController.php b/core/modules/forum/lib/Drupal/forum/ForumFormController.php index e300ba5..4bce670 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumFormController.php +++ b/core/modules/forum/lib/Drupal/forum/ForumFormController.php @@ -8,11 +8,13 @@ namespace Drupal\forum; use Drupal\taxonomy\TermFormController; +use Drupal\Core\Entity\EntityControllerInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Base form controller for forum term edit forms. */ -class ForumFormController extends TermFormController { +class ForumFormController extends TermFormController implements EntityControllerInterface { /** * Reusable type field to use in status messages. @@ -29,6 +31,36 @@ class ForumFormController extends TermFormController { protected $urlStub = 'forum'; /** + * The forum config. + * + * @var \Drupal\Core\Config\Config + */ + protected $config; + + /** + * Constructs a new MenuLinkFormController object. + * + * @param string $operation + * The name of the current operation. + * @param \Drupal\Core\Config\ConfigFactory $config_factory + * The config factory service. + */ + public function __construct($operation, ConfigFactory $config_factory) { + parent::__construct($operation); + $this->config = $config_factory->get('forum.settings'); + } + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, $entity_type, array $entity_info, $operation = NULL) { + return new static( + $operation, + $container->get('config.factory') + ); + } + + /** * {@inheritdoc} */ public function form(array $form, array &$form_state) { @@ -133,8 +165,7 @@ protected function forumParentSelect($tid, $title) { $parent = 0; } - // @todo Inject config factory once possible. - $vid = config('forum.settings')->get('vocabulary'); + $vid = $this->config->get('vocabulary'); $children = taxonomy_get_tree($vid, $tid, NULL, TRUE); // A term can't be the child of itself, nor of its children.