Service definition helpers
Helper module adds enhancements for defining services.
Service tags
module_dependency
Indicates a service requires a certain module to be enabled. This is run by \Drupal\helper\Compiler\ModuleDependencyPass.
Usage
services:
_defaults:
autowire: true
my_module.other_module_service:
class: Drupal\my_module\OtherModuleService
tags:
- { name: module_dependency, module: other_module }
Drupal\my_module\OtherModuleService: '@my_module.other_module_service'
Both the my_module.other_module_service service and its OtherModuleService::class alias will be removed if the other_module is not enabled.