Use Typed Configs for Drupal 11

Created on 4 December 2024, 3 months ago

Re-creating this issue from #3490317 as I've made a mess of the git history in my first attempt. Apologies u/jwjoshuawalker β†’ , I am still getting oriented to Drupal GitLab and contrib module workflow.

Problem/Motivation

Not having looked far into this, I suspect it is a Drupal 11 issue. I also recognize the module does not indicate Drupal 11 as supported (yet). I'd like to try to test this out as a possible module rather than developing custom theme code for responsive menuii.

Steps to reproduce

Install module on Drupal 11

Observe error message on module admin page (/admin/config/user-interface/responsive_menus)

ArgumentCountError: Too few arguments to function Drupal\Core\Form\ConfigFormBase::__construct(), 1 passed in /var/www/html/web/modules/contrib/responsive_menus/src/Form/ResponsiveMenusAdminForm.php on line 29 and exactly 2 expected in Drupal\Core\Form\ConfigFormBase->__construct() (line 43 of core/lib/Drupal/Core/Form/ConfigFormBase.php).

Proposed resolution

Implement and test in an issue branch:

<?php

namespace Drupal\responsive_menus\Form;

use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\responsive_menus\ResponsiveMenusPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Form class for managing responsive menus in the administration interface.
 *
 * @package Drupal\responsive_menus\Form
 */
class ResponsiveMenusAdminForm extends ConfigFormBase {

  /**
   * The Responsive Menus plugin manager.
   *
   * @var \Drupal\responsive_menus\ResponsiveMenusPluginManager
   */
  protected ResponsiveMenusPluginManager $pluginManager;

  /**
   * {@inheritdoc}
   */
  public function __construct(ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config_manager, ResponsiveMenusPluginManager $plugin_manager) {
    parent::__construct($config_factory, $typed_config_manager);

    $this->pluginManager = $plugin_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('config.factory'),
      $container->get('config.typed'),
      $container->get('plugin.manager.responsive_menus')
    );
  }

//...

Remaining tasks

Set up dev branch based on this issue

Allow Drupal 11 support

Implement proposed minor fix

Test

User interface changes

None

API changes

None

Data model changes

None

πŸ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States axb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024