ComponentPluginManager decorator incorrectly calls parent instead of decorated service

Created on 11 October 2025, 20 days ago

Problem/Motivation

The service decorator Drupal\ui_patterns\ComponentPluginManager is incorrectly implemented.
It extends Drupal\Core\Theme\ComponentPluginManager and calls parent:: methods instead of using the decorated service.
This bypasses Drupal’s service decoration mechanism, so additional decorators or alternative implementations of component_plugin_manager are ignored.

Expected Behavior

The ComponentPluginManager in ui_patterns should call the decorated service, not the parent class.

// Wrong (current implementation):
parent::processDefinition($definition, $plugin_id);

// Correct (expected behavior):
$this->decorated->processDefinition($definition, $plugin_id);

Proposed Resolution

  • Inject the decorated component_plugin_manager service via the constructor.
  • Replace all parent:: calls with calls to $this->decorated.
<?php

use Drupal\Core\Theme\ComponentPluginManagerInterface;

class ComponentPluginManager implements ComponentPluginManagerInterface {

  protected ComponentPluginManagerInterface $decorated;

  public function __construct(ComponentPluginManagerInterface $decorated) {
    $this->decorated = $decorated;
  }

  public function processDefinition(&$definition, $plugin_id) {
    // Delegate to the decorated service.
    $this->decorated->processDefinition($definition, $plugin_id);
    // Add ui_patterns-specific logic here if needed.
  }

  // Delegate other methods likewise...
}

Impact

  • Breaks Drupal’s service decoration mechanism.
  • Prevents other modules from properly decorating component_plugin_manager.
  • Reduces extensibility and violates expected Drupal service design.

Summary

Drupal\ui_patterns\ComponentPluginManager should delegate to the decorated service, not the parent class, to correctly follow Drupal’s service decoration pattern and maintain extensibility.

Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

🇩🇪Germany Christian.wiedemann

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024