This is part of #1924990: [meta] Convert all of system_config_form() to SystemConfigFormBase

Problem/Motivation

More consistent use of SystemConfigFormBase

Proposed resolution

Convert it to use SystemConfigFormBase

Remaining tasks

Write patch

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan’s picture

larowlan’s picture

Status: Postponed » Active

This now unblocked

larowlan’s picture

Assigned: larowlan » Unassigned
Status: Active » Needs review
FileSize
7.2 KB

lets see how this goes

Kars-T’s picture

The patch just wraps the ForumSettingsForm in an object and uses symfony routing. This results in cleaner and better code.

I applied the patch and checked the functionality. Everything seems to work and I'd say it is RTBC.

The problem is there doesn't seem to be any tests for the functionality controlled by this form. So I can't easily confirm this patch doesn't change anything. I'd say we need tests for this. Or maybe the whole functionality could / should be moved to views?

tim.plunkett’s picture

Status: Needs review » Needs work

This needs to be rerolled to take advantage of the recent improvements to forms. See #1924990-5: [meta] Convert all of system_config_form() to SystemConfigFormBase

Kars-T’s picture

Hi Tim

I think it already uses the new version?

class ForumSettingsForm extends SystemConfigFormBase {
tim.plunkett’s picture

+++ b/core/modules/forum/forum.routing.ymlundefined
@@ -0,0 +1,6 @@
+  defaults:
+    _controller: 'forum.form.settings:getForm'

+++ b/core/modules/forum/lib/Drupal/forum/ForumBundle.phpundefined
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\forum\ForumBundle.
+ */
+
+namespace Drupal\forum;
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\HttpKernel\Bundle\Bundle;
+
+/**
+ * Forum dependency injection container.
+ */
+class ForumBundle extends Bundle {
+
+  /**
+   * Overrides Symfony\Component\HttpKernel\Bundle\Bundle::build().
+   */
+  public function build(ContainerBuilder $container) {
+    $container->register('forum.form.settings', 'Drupal\forum\ForumSettingsForm')
+      ->addArgument(new Reference('config.factory'));
+  }
+

+++ b/core/modules/forum/lib/Drupal/forum/ForumSettingsForm.phpundefined
@@ -0,0 +1,101 @@
+use Drupal\Core\Config\ConfigFactory;
...
+  /**
+   * Stores the configuration factory.
+   *
+   * @var \Drupal\Core\Config\ConfigFactory
+   */
+  protected $configFactory;
+
+  /**
+   * Constructs a \Drupal\forum\ForumSettingsForm object.
+   *
+   * @param \Drupal\Core\Config\ConfigFactory $config_factory
+   *   The factory for configuration objects.
+   */
+  public function __construct(ConfigFactory $config_factory) {
+    $this->configFactory = $config_factory;
+  }
+
+  /**
+   * Returns an instance of this form.
+   */
+  public function getForm() {
+    return drupal_get_form($this);

All of this can go away, and just have _form: 'Drupal\forum\ForumSettingsForm' in the YAML file.

larowlan’s picture

Status: Needs work » Needs review
FileSize
5.73 KB
2.53 KB

Refactor to take into account new _form system

amateescu’s picture

Status: Needs review » Needs work
+++ b/core/modules/forum/forum.module
@@ -138,8 +138,7 @@ function forum_menu() {
-    'page callback' => 'drupal_get_form',
-    'page arguments' => array('forum_admin_settings'),
+    'page callback' => 'NOT_USED',
     'access arguments' => array('administer forums'),

The page callback is not necessary anymore, this should change to: 'route_name' => 'forum_settings'. And you can remove the access callback as well.

+++ b/core/modules/forum/forum.routing.yml
@@ -0,0 +1,6 @@
\ No newline at end of file

:)

larowlan’s picture

Priority: Major » Normal
Status: Needs work » Needs review
FileSize
5.9 KB
1.08 KB

This shouldn't have been major, the META is major.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Looks good now.

xjm’s picture

xjm’s picture

Issue tags: +Quick fix
FileSize
34.31 KB
38.91 KB

Tested manually -- looks great. Submissions work fine.

Before:
before.png

After:
after.png

(Note: the different values are from me testing the submission.) ;)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Looks good!

Committed and pushed to 8.x. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.