Use autowiring for core controllers

Created on 24 October 2023, about 1 year ago
Updated 19 January 2024, 11 months ago

Problem/Motivation

Following ๐Ÿ“Œ Allow controller service wiring via constructor parameter attributes Fixed we can autowire many classes in core that extend ControllerBase by deleting the create() method.

This provides a good example for contrib and custom code to follow, and should mean we can delete hundreds of lines of boilerplate code.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ“Œ Task
Status

Fixed

Version

11.0 ๐Ÿ”ฅ

Component
Baseย  โ†’

Last updated 2 days ago

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

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

Comments & Activities

  • Issue created by @longwave
  • Status changed to Active about 1 year ago
  • @longwave opened merge request.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    First pass at this.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Seems to have CC failures.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Nitin shrivastava

    Nitin shrivastava โ†’ made their first commit to this issueโ€™s fork.

  • First commit to issue fork.
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands spokje
  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Very neat.

    Ran the test-only feature

    There was 1 failure:
    1) Drupal\KernelTests\Core\DependencyInjection\AutowireTest::testCoreControllerAutowiring
    The following core controllers can be autowired. Remove the create() method:
    \Drupal\views_ui\Controller\ViewsUIController
    \Drupal\update\Controller\UpdateController
    \Drupal\tracker\Controller\TrackerController
    \Drupal\system\CronController
    \Drupal\system\Controller\ThemeController
    \Drupal\system\FileDownloadController
    \Drupal\shortcut\Controller\ShortcutSetController
    \Drupal\search\Controller\SearchController
    \Drupal\menu_ui\Controller\MenuController
    \Drupal\help\Controller\HelpTopicPluginController
    \Drupal\dblog\Controller\DbLogController
    \Drupal\contact\Controller\ContactController
    \Drupal\config_translation\Controller\ConfigTranslationListController
    \Drupal\comment\Controller\CommentController
    \Drupal\ckeditor5\Controller\CKEditor5MediaController
    \Drupal\book\Controller\BookController
    \Drupal\block\Controller\BlockController
    \Drupal\block\Controller\BlockListController
    \Drupal\announcements_feed\Controller\AnnounceController
    Failed asserting that an array is empty.
    

    So check seems good. And deletions didn't break anything. Think we can rely on the tests on this one. Controllers pretty important in the existing tests :)

    • larowlan โ†’ committed 83752e6b on 11.x
      Issue #3396310 by longwave, Spokje, smustgrave: Use autowiring for core...
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Committed to 11.x

    Waiting on second opinion about whether this still qualifies for 10.2.x

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK

    Too late for 10.2.x now, marking as fixed in 11.x.

  • Status changed to Fixed 12 months ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom longwave UK
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024