public function JsonapiExtrasServiceProvider::alter in JSON:API Extras 8
Same name and namespace in other branches
- 8.3 src/JsonapiExtrasServiceProvider.php \Drupal\jsonapi_extras\JsonapiExtrasServiceProvider::alter()
- 8.2 src/JsonapiExtrasServiceProvider.php \Drupal\jsonapi_extras\JsonapiExtrasServiceProvider::alter()
Modifies existing service definitions.
Parameters
ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered.
Overrides ServiceProviderBase::alter
File
- src/
JsonapiExtrasServiceProvider.php, line 18
Class
- JsonapiExtrasServiceProvider
- Replace the resource type repository for our own configurable version.
Namespace
Drupal\jsonapi_extrasCode
public function alter(ContainerBuilder $container) {
if ($container
->has('jsonapi.resource_type.repository')) {
// Override the class used for the configurable service.
$definition = $container
->getDefinition('jsonapi.resource_type.repository');
$definition
->setClass(ConfigurableResourceTypeRepository::class);
// The configurable service expects the entity repository and the enhancer
// plugin manager.
$definition
->addArgument(new Reference('entity.repository'));
$definition
->addArgument(new Reference('plugin.manager.resource_field_enhancer'));
$definition
->addArgument(new Reference('config.factory'));
}
}