SDC: Add a method to retrieve only components not replaced by others

Created on 5 October 2023, about 1 year ago
Updated 18 June 2024, 6 months ago

Problem/Motivation

We are planning to rewrite UI Patterns β†’ upon SDC. To achieve this, we are proposing a few changes and additions:

ComponentPluginManager::getAllComponents() is useful to retrieve all the components.

However, we sometimes needs a list of the components minus the ones replaced by others. For example:

  • An UI for selecting components while doing site building
  • A library page
  • Some controls in code

A replaced component is not "active" anymore, so it makes little sense to display it.

Proposed resolution

Add a boolean parameter to ComponentPluginManager::getAllComponents():

public function getAllComponents(bool $filter = FALSE): array {

For better control, this parameter can be an integer like what is done in StreamWrapperManagerInterface::getWrappers:

public function getAllComponents(int $filter = 0): array {

Or add a new public function to ComponentPluginManager:

public function getActiveComponents(): array {

I guess "active" a good keyword for components which are not replaced by others. So, we can add other unrelated rules later (according to some status or conditions).

Remaining tasks

If there is a chance for this feature to be accepted, we (UI Patterns team) can propose a merge request soon.

We have one month before the release of Drupal 10.2.0-alpha1.

✨ Feature request
Status

Needs work

Version

11.0 πŸ”₯

Component
single-directory componentsΒ  β†’

Last updated about 6 hours ago

Created by

πŸ‡«πŸ‡·France pdureau Paris

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024