Use default ContainerFactory instead of DefaultFactory in TabTypeManager

Created on 30 March 2022, over 2 years ago
Updated 30 March 2023, over 1 year ago

Problem/Motivation

The TabTypeManager specifies the DefaultFactory to use, which ironically is not the default. DefaultFactory means that a plugin cannot use ContainerFactoryPluginInterface to inject its dependencies. It is a best practice to use dependency injection rather than the global \Drupal object.

Steps to reproduce

1. Implement a TabType class that implements ContainerFactoryPluginInterface and injects another dependency.
2. Try to instantiate a QuickTabsInstance with a tab using that tab type.
3. An exception will be thrown because TabTypeManager will try to create the plugin instance with default arguments.

Proposed resolution

Remove the line in TabTypemanager, $this->factory = new DefaultFactory($this->getDiscovery());<code>. This will let DefaultPluginManager use the default factory, which is <code>ContainerFactory

Remaining tasks

1. Create an issue fork and merge request with the line removed.
2. Optionally fix one of the tab types to inject dependencies instead.
3. See if tests pass.

User interface changes

No

API changes

It becomes possible to inject dependencies rather than use global Drupal object.

Data model changes

No

✨ Feature request
Status

RTBC

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mradcliffe USA

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.

Production build 0.69.0 2024