Problem/Motivation
I won't be possible to override any service that doesn't implement an interface so all core services should implement an interface.
Proposed resolution
- Create interfaces for all core services.
- Document any core services that for some reason can not implement an interface.
- Update references to all services which are injected in core to use the interface.
Remaining tasks
Check all core services for interface implementation.
Create sub tasks for any core services which fail to implement an interface.
Create interfaces or documentation to correct sub-tasks the issue for each case.
User interface changes
None
API changes
Injected dependencies will have to inject the interface instead of the implementation class directly.
Classes needing interfaces
\Drupal\Core\Access\CsrfTokenGenerator
\Drupal\Core\AppRootFactory
\Drupal\Core\Asset\LibraryDiscoveryParser
#2580757: Create an interface for \Drupal\Core\Cache\Context\CacheContextsManager
\Drupal\Core\Diff\DiffFormatter
#2580767: Create an interface for \Drupal\Core\Entity\EntityAutocompleteMatcher
#2580763: Create an interface for \Drupal\Core\Entity\EntityResolverManager
\Drupal\Core\Entity\Query\QueryFactory
\Drupal\Core\Http\ClientFactory
\Drupal\Core\Http\HandlerStackConfigurator
\Drupal\Core\Image\ImageFactory
\Drupal\Core\Language\LanguageDefault
\Drupal\Core\Menu\DefaultMenuLinkTreeManipulators
\Drupal\Core\Path\CurrentPathStack
\Drupal\Core\PrivateKey
\Drupal\Core\Queue\QueueDatabaseFactory
\Drupal\Core\Queue\QueueFactory
\Drupal\Core\Routing\AdminContext
\Drupal\Core\Routing\RequestContext
\Drupal\Core\SitePathFactory
\Drupal\Core\Theme\Registry
\Drupal\Core\Update\UpdateRegistry
\Drupal\Core\Update\UpdateRegistryFactory
\Drupal\Core\Utility\Token (WTF, why is a utility a service?)
\Drupal\Core\Site\Settings this is final, seems purposeful
The following do not have interfaces, but directly extend from upstream classes:
\Drupal\Core\Template\Loader\FilesystemLoader
\Drupal\Core\Template\Loader\ThemeRegistryLoader
\Drupal\Core\Template\TwigEnvironment
\Drupal\Core\Template\TwigExtension
Data model changes
None
Beta phase evaluation
| Issue category | Task because services work without a specific interface. It just hampers the service's extensibility. |
|---|---|
| Issue priority | Major because contrib modules will have a hard if something just won't work in a service for the module's use case. Not critical because drupal 8 does not override services in core. |
| Disruption | I don't think this would be disruptive for contrib because it only affects services that cannot currently be overridden but each service should be evaluated on it's own to determine possible disruptions. |
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 2572181-core-services-8c.patch | 125.57 KB | marvin_b8 |
Comments
Comment #2
Jaesin commentedI think services will have to implement their own interface. For instance, if a service injects
class ConditionManager extends DefaultPluginManager implements ExecutableManagerInterface, CategorizingPluginManagerInterfaceThey will probably usepublic function __construct(\ConditionManager $condition_manager.... If that service is overridden, this constructor will error out.Comment #3
marvin_b8 commentedOnly Extend some class
Implement no interface and don't extend another class
a list of all services will follow if necessary
Comment #4
marvin_b8 commentedOnly static methods so we don't need a interface for the following classes:
By this classes i'm not sure if we need some interfaces:
In think all of this classes need a interface.
Because the have some method that are not in the interface of the extend class.
And this classes are ok
And as attachment the first patch.
It's only adds to all classes without a interface, a interface.
Comment #7
Jaesin commented@marvin_B8 Thanks for diving into this.
Here are a couple of tips about the patch.
Let's make sure to add newlines to the end of files.
perfect, This is exactly the kind of thing that gets us into trouble.
"AdminContext" should be "AdminContextInterface" This looks like the primary reason the test is failing.
Comment #8
marvin_b8 commentedanother try
Comment #10
Anonymous (not verified) commentedCreating an interface for the DateFormatter service has a separate issue which is RTBC: #2571647: Create DateFormatterInterface.
Keeping it there will make this patch less intrusive.
Comment #12
Jaesin commented@pjonckiere Thanks for the note. I totally agree.
All patches should go in a sub-task and be dealt with individually so their risks and validity can be evaluated separately.
Comment #13
legolasboLet's convert this to a meta issue and create sub-issues for each service in need of an interface, that will result in less intrusive and reviewable patches which can be committed more easily.
Comment #14
Jaesin commentedAdding [META] to the title and a beta evaluation.
Comment #15
mpdonadioAdded Tim's findings from #2580739: [META] All core services should implement an interface