class JsonapiServiceProvider
Same name in other branches
- 8.9.x core/modules/jsonapi/src/JsonapiServiceProvider.php \Drupal\jsonapi\JsonapiServiceProvider
- 10 core/modules/jsonapi/src/JsonapiServiceProvider.php \Drupal\jsonapi\JsonapiServiceProvider
- 11.x core/modules/jsonapi/src/JsonapiServiceProvider.php \Drupal\jsonapi\JsonapiServiceProvider
Adds 'api_json' as known format and prevents its use in the REST module.
@internal JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it.
Hierarchy
- class \Drupal\jsonapi\JsonapiServiceProvider implements \Drupal\Core\DependencyInjection\ServiceModifierInterface, \Drupal\Core\DependencyInjection\ServiceProviderInterface
Expanded class hierarchy of JsonapiServiceProvider
See also
https://www.drupal.org/project/drupal/issues/3032787
File
-
core/
modules/ jsonapi/ src/ JsonapiServiceProvider.php, line 20
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(), NegotiationMiddleware::class, 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());
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
JsonapiServiceProvider::alter | public | function | Modifies existing service definitions. | Overrides ServiceModifierInterface::alter |
JsonapiServiceProvider::register | public | function | Registers services to the container. | Overrides ServiceProviderInterface::register |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.