Problem/Motivation
The Seeds Widgets module currently uses static service calls (\Drupal::service()) and doesn't follow Drupal best practices for dependency injection. This makes the code:

Harder to test with unit tests
Difficult to override services
Non-compliant with Drupal coding standards
Harder to maintain
Proposed resolution
Implement proper dependency injection across the entire module:

1. Field Formatters (8 files)

Implement ContainerFactoryPluginInterface in all formatters
Inject
SeedsWidgetsManager
and EntityTypeManagerInterface
Inject ConfigFactoryInterface for CarouselFormatter and SliderFormatter
Use injected services instead of static calls
2. SeedsWidgetsManager Service

Inject: Renderer, ImageFactory, CurrentRouteMatch, ConfigFactoryInterface, EntityDisplayRepositoryInterface
Update service definition in
seeds_widgets.services.yml
3. BlocksTabsBlock Plugin

Inject: BlockManagerInterface, ContextRepositoryInterface, UuidInterface
Convert
addMoreCallback()
from static to instance method
Fix service locator anti-pattern
4. ParagraphViewModesForm

Inject EntityDisplayRepositoryInterface
Use injected service in form methods

Comments

ahmad-alyasaki created an issue. See original summary.

  • f5594279 committed on 2.0.x
    feat: #3560268 Implement dependency injection for services, plugins, and...
ahmad-alyasaki’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.