Problem/Motivation
The decorator pattern is a nice concept; however, in practice, decorated services can be challenging. In the case of this module, the challenge is avoiding duplicative code.
In Drupal 12, the ProviderRepository typehint on the $repository property in Drupal\Tests\media\Unit\ProviderRepositoryTest was added in #3585505: Refactor tests code via Rector. In our extended test, the property is of type ProviderRepositoryDecorator, which causes a fatal error.
One solution would be to copy the Drupal\Tests\media\Unit\ProviderRepositoryTest test class and modify it; however, this would defeat the purpose. The purpose of extending the test is to ensure core test coverage still passes (especially given potential core updates) with our decorator.
This issue blocks a D12-compatible release: #3601656: Automated Drupal 12 compatibility fixes for oembed_providers 2.x-dev.
Proposed resolution
The least bad solution is to abandon the decorator pattern and instead alter the media.oembed.provider_repository service by replacing its ProviderRepository class with our class, which would extend the replaced core class.
We'll want to update README and the project page to state that this module is incompatible with any other module that decorates or modifies the media.oembed.provider_repository service. This may be a breaking change, so it'll require a 3.0.0 release.
Remaining tasks
- Open MR
- Passing tests
User interface changes
None.
API changes
Shift from decorator pattern to replacing service class.
Data model changes
None.
Issue fork oembed_providers-3614309
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
chris burge commentedComment #6
chris burge commented