class JsonapiServiceProvider in JSON:API 8
Same name and namespace in other branches
- 8.2 src/JsonapiServiceProvider.php \Drupal\jsonapi\JsonapiServiceProvider
Adds 'api_json' as known format and prevents its use in the REST module.
@internal
Hierarchy
- class \Drupal\jsonapi\JsonapiServiceProvider implements ServiceModifierInterface, ServiceProviderInterface
Expanded class hierarchy of JsonapiServiceProvider
File
- src/
JsonapiServiceProvider.php, line 17
Namespace
Drupal\jsonapiView source
class JsonapiServiceProvider implements ServiceModifierInterface, ServiceProviderInterface {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
if ($container
->has('http_middleware.negotiation') && is_a($container
->getDefinition('http_middleware.negotiation')
->getClass(), '\\Drupal\\Core\\StackMiddleware\\NegotiationMiddleware', TRUE)) {
// @see http://www.iana.org/assignments/media-types/application/vnd.api+json
$container
->getDefinition('http_middleware.negotiation')
->addMethodCall('registerFormat', [
'api_json',
[
'application/vnd.api+json',
],
]);
}
}
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
$container
->addCompilerPass(new RegisterSerializationClassesCompilerPass());
$container
->addCompilerPass(new RemoveJsonapiFormatCompilerPass(), PassConfig::TYPE_REMOVE);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JsonapiServiceProvider:: |
public | function |
Modifies existing service definitions. Overrides ServiceModifierInterface:: |
|
JsonapiServiceProvider:: |
public | function |
Registers services to the container. Overrides ServiceProviderInterface:: |