Do not use ControllerBase as parent class for RestExampleClientController

Created on 1 July 2024, 10 months ago
Updated 15 July 2024, 9 months ago

The \Drupal\rest_example\Controller\RestExampleClientController class extends \Drupal\Core\Controller\ControllerBase, but the only method it uses from that class is config().

Instead of extending ControllerBase, RestExampleClientController should:

  • Implement \Drupal\Core\DependencyInjection\ContainerInjectionInterface
  • Use \Drupal\Core\Messenger\MessengerTrait
  • Use \Drupal\Core\StringTranslation\StringTranslationTrait
  • Define a property for the configuration factory service

RestExampleClientController actually accesses ControllerBase::$configFactory before it is initialized with the effect of accessing a method on NULL.
Changing the class as described here fixes that bug too.

📌 Task
Status

Fixed

Version

4.0

Component

REST Example

Created by

🇮🇹Italy apaderno Brescia, 🇮🇹

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