You are here

jsonapi.services.yml in Drupal 9

core/modules/jsonapi/jsonapi.services.yml

File

core/modules/jsonapi/jsonapi.services.yml
View source
  1. parameters:
  2. jsonapi.base_path: /jsonapi
  3. services:
  4. jsonapi.serializer:
  5. class: Drupal\jsonapi\Serializer\Serializer
  6. calls:
  7. - [setFallbackNormalizer, ['@serializer']]
  8. arguments: [{ }, { }]
  9. serializer.normalizer.http_exception.jsonapi:
  10. class: Drupal\jsonapi\Normalizer\HttpExceptionNormalizer
  11. arguments: ['@current_user']
  12. tags:
  13. - { name: jsonapi_normalizer }
  14. serializer.normalizer.unprocessable_entity_exception.jsonapi:
  15. class: Drupal\jsonapi\Normalizer\UnprocessableHttpEntityExceptionNormalizer
  16. arguments: ['@current_user']
  17. tags:
  18. # This must have a higher priority than the 'serializer.normalizer.http_exception.jsonapi' to take effect.
  19. - { name: jsonapi_normalizer, priority: 1 }
  20. serializer.normalizer.entity_access_exception.jsonapi:
  21. class: Drupal\jsonapi\Normalizer\EntityAccessDeniedHttpExceptionNormalizer
  22. arguments: ['@current_user']
  23. tags:
  24. # This must have a higher priority than the 'serializer.normalizer.http_exception.jsonapi' to take effect.
  25. - { name: jsonapi_normalizer, priority: 1 }
  26. serializer.normalizer.field_item.jsonapi:
  27. class: Drupal\jsonapi\Normalizer\FieldItemNormalizer
  28. arguments: ['@entity_type.manager']
  29. tags:
  30. - { name: jsonapi_normalizer }
  31. serializer.normalizer.field.jsonapi:
  32. class: Drupal\jsonapi\Normalizer\FieldNormalizer
  33. tags:
  34. - { name: jsonapi_normalizer }
  35. serializer.normalizer.resource_identifier.jsonapi:
  36. class: Drupal\jsonapi\Normalizer\ResourceIdentifierNormalizer
  37. arguments: ['@entity_field.manager']
  38. tags:
  39. - { name: jsonapi_normalizer }
  40. serializer.normalizer.data.jsonapi:
  41. class: Drupal\jsonapi\Normalizer\DataNormalizer
  42. tags:
  43. - { name: jsonapi_normalizer }
  44. serializer.normalizer.resource_object.jsonapi:
  45. class: Drupal\jsonapi\Normalizer\ResourceObjectNormalizer
  46. arguments: ['@jsonapi.normalization_cacher']
  47. tags:
  48. - { name: jsonapi_normalizer }
  49. jsonapi.normalization_cacher:
  50. class: Drupal\jsonapi\EventSubscriber\ResourceObjectNormalizationCacher
  51. calls:
  52. - ['setRenderCache', ['@render_cache']]
  53. tags:
  54. - { name: event_subscriber }
  55. serializer.normalizer.content_entity.jsonapi:
  56. class: Drupal\jsonapi\Normalizer\ContentEntityDenormalizer
  57. arguments: ['@entity_type.manager', '@entity_field.manager', '@plugin.manager.field.field_type']
  58. tags:
  59. - { name: jsonapi_normalizer }
  60. serializer.normalizer.config_entity.jsonapi:
  61. class: Drupal\jsonapi\Normalizer\ConfigEntityDenormalizer
  62. arguments: ['@entity_type.manager', '@entity_field.manager', '@plugin.manager.field.field_type']
  63. tags:
  64. - { name: jsonapi_normalizer }
  65. serializer.normalizer.jsonapi_document_toplevel.jsonapi:
  66. class: Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer
  67. arguments: ['@entity_type.manager', '@jsonapi.resource_type.repository']
  68. tags:
  69. - { name: jsonapi_normalizer }
  70. serializer.normalizer.link_collection.jsonapi:
  71. class: Drupal\jsonapi\Normalizer\LinkCollectionNormalizer
  72. arguments: ['@current_user']
  73. tags:
  74. - { name: jsonapi_normalizer }
  75. serializer.normalizer.relationship.jsonapi:
  76. class: Drupal\jsonapi\Normalizer\RelationshipNormalizer
  77. tags:
  78. - { name: jsonapi_normalizer }
  79. serializer.encoder.jsonapi:
  80. class: Drupal\jsonapi\Encoder\JsonEncoder
  81. tags:
  82. - { name: jsonapi_encoder, format: 'api_json' }
  83. jsonapi.resource_type.repository:
  84. class: Drupal\jsonapi\ResourceType\ResourceTypeRepository
  85. arguments: ['@entity_type.manager', '@entity_type.bundle.info', '@entity_field.manager', '@cache.jsonapi_resource_types', '@event_dispatcher']
  86. jsonapi.route_enhancer:
  87. class: Drupal\jsonapi\Routing\RouteEnhancer
  88. tags:
  89. - { name: route_enhancer }
  90. jsonapi.field_resolver:
  91. class: Drupal\jsonapi\Context\FieldResolver
  92. arguments: ['@entity_type.manager', '@entity_field.manager', '@entity_type.bundle.info', '@jsonapi.resource_type.repository', '@module_handler', '@current_user']
  93. jsonapi.include_resolver:
  94. class: Drupal\jsonapi\IncludeResolver
  95. arguments:
  96. - '@entity_type.manager'
  97. - '@jsonapi.entity_access_checker'
  98. paramconverter.jsonapi.entity_uuid:
  99. parent: paramconverter.entity
  100. class: Drupal\jsonapi\ParamConverter\EntityUuidConverter
  101. calls:
  102. - [setLanguageManager, ['@language_manager']]
  103. tags:
  104. # Priority 10, to ensure it runs before @paramconverter.entity.
  105. - { name: paramconverter, priority: 10 }
  106. paramconverter.jsonapi.resource_type:
  107. class: Drupal\jsonapi\ParamConverter\ResourceTypeConverter
  108. arguments: ['@jsonapi.resource_type.repository']
  109. tags:
  110. - { name: paramconverter }
  111. jsonapi.exception_subscriber:
  112. class: Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber
  113. tags:
  114. - { name: event_subscriber }
  115. arguments: ['@jsonapi.serializer', '%serializer.formats%']
  116. logger.channel.jsonapi:
  117. parent: logger.channel_base
  118. arguments: ['jsonapi']
  119. # Cache.
  120. cache.jsonapi_memory:
  121. class: Drupal\Core\Cache\MemoryCache\MemoryCache
  122. public: false
  123. # A chained cache with an in-memory cache as the first layer and a database-
  124. # backed cache as the fallback is used. The first layer (memory) is necessary
  125. # because ResourceType value objects are retrieved many times during a
  126. # request. The second layer (by default a database) is necessary to avoid
  127. # recomputing the ResourceType value objects on every request.
  128. cache.jsonapi_resource_types:
  129. class: Drupal\Core\Cache\BackendChain
  130. calls:
  131. - [appendBackend, ['@cache.jsonapi_memory']]
  132. - [appendBackend, ['@cache.default']]
  133. tags: [{ name: cache.bin }]
  134. cache.jsonapi_normalizations:
  135. class: Drupal\Core\Cache\CacheBackendInterface
  136. tags:
  137. - { name: cache.bin }
  138. factory: ['@cache_factory', 'get']
  139. arguments: [jsonapi_normalizations]
  140. # Route filter.
  141. jsonapi.route_filter.format_setter:
  142. class: Drupal\jsonapi\Routing\EarlyFormatSetter
  143. tags:
  144. # Set to a high priority so it runs before content_type_header_matcher
  145. # and other filters that might throw exceptions.
  146. - { name: route_filter, priority: 100 }
  147. # Access Control
  148. jsonapi.entity_access_checker:
  149. class: Drupal\jsonapi\Access\EntityAccessChecker
  150. public: false
  151. arguments: ['@jsonapi.resource_type.repository', '@router.no_access_checks', '@current_user', '@entity.repository']
  152. calls:
  153. - [setNodeRevisionAccessCheck, ['@?access_check.node.revision']] # This is only injected when the service is available.
  154. - [setMediaRevisionAccessCheck, ['@?access_check.media.revision']] # This is only injected when the service is available.
  155. # This is a temporary measure. JSON:API should not need to be aware of the Content Moderation module.
  156. - [setLatestRevisionCheck, ['@?access_check.latest_revision']] # This is only injected when the service is available.
  157. access_check.jsonapi.relationship_route_access:
  158. class: Drupal\jsonapi\Access\RelationshipRouteAccessCheck
  159. arguments: ['@jsonapi.entity_access_checker']
  160. tags:
  161. - { name: access_check, applies_to: _jsonapi_relationship_route_access }
  162. # Route filters.
  163. method_filter.jsonapi:
  164. public: false
  165. class: Drupal\jsonapi\Routing\ReadOnlyModeMethodFilter
  166. decorates: method_filter
  167. arguments: ['@method_filter.jsonapi.inner', '@config.factory']
  168. # Controller.
  169. jsonapi.entity_resource:
  170. class: Drupal\jsonapi\Controller\EntityResource
  171. arguments:
  172. - '@entity_type.manager'
  173. - '@entity_field.manager'
  174. - '@jsonapi.resource_type.repository'
  175. - '@renderer'
  176. - '@entity.repository'
  177. - '@jsonapi.include_resolver'
  178. - '@jsonapi.entity_access_checker'
  179. - '@jsonapi.field_resolver'
  180. - '@jsonapi.serializer'
  181. - '@datetime.time'
  182. - '@current_user'
  183. jsonapi.file_upload:
  184. class: Drupal\jsonapi\Controller\FileUpload
  185. arguments:
  186. - '@current_user'
  187. - '@entity_field.manager'
  188. - '@jsonapi.file.uploader.field'
  189. - '@http_kernel'
  190. # Event subscribers.
  191. jsonapi.custom_query_parameter_names_validator.subscriber:
  192. class: Drupal\jsonapi\EventSubscriber\JsonApiRequestValidator
  193. tags:
  194. - { name: event_subscriber }
  195. jsonapi.resource_response.subscriber:
  196. class: Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber
  197. arguments: ['@jsonapi.serializer']
  198. tags:
  199. - { name: event_subscriber }
  200. jsonapi.resource_response_validator.subscriber:
  201. class: Drupal\jsonapi\EventSubscriber\ResourceResponseValidator
  202. arguments: ['@logger.channel.jsonapi', '@module_handler', '%app.root%']
  203. calls:
  204. - [setValidator, []]
  205. tags:
  206. - { name: event_subscriber, priority: 1000 }
  207. # Revision management.
  208. jsonapi.version_negotiator:
  209. class: Drupal\jsonapi\Revisions\VersionNegotiator
  210. public: false
  211. tags:
  212. - { name: service_collector, tag: jsonapi_version_negotiator, call: addVersionNegotiator }
  213. jsonapi.version_negotiator.default:
  214. arguments: ['@entity_type.manager']
  215. public: false
  216. abstract: true
  217. jsonapi.version_negotiator.id:
  218. class: Drupal\jsonapi\Revisions\VersionById
  219. parent: jsonapi.version_negotiator.default
  220. tags:
  221. - { name: jsonapi_version_negotiator, negotiator_name: 'id' }
  222. jsonapi.version_negotiator.rel:
  223. class: Drupal\jsonapi\Revisions\VersionByRel
  224. parent: jsonapi.version_negotiator.default
  225. tags:
  226. - { name: jsonapi_version_negotiator, negotiator_name: 'rel' }
  227. jsonapi.resource_version.route_enhancer:
  228. class: Drupal\jsonapi\Revisions\ResourceVersionRouteEnhancer
  229. public: false
  230. arguments:
  231. - '@jsonapi.version_negotiator'
  232. tags:
  233. - { name: route_enhancer }
  234. # @todo Remove once https://www.drupal.org/project/drupal/issues/2940383 lands.
  235. jsonapi.file.uploader.field:
  236. class: Drupal\jsonapi\Controller\TemporaryJsonapiFileFieldUploader
  237. public: false
  238. arguments: ['@logger.channel.file', '@file_system', '@file.mime_type.guesser', '@token', '@lock', '@config.factory']
  239. # Deprecated services.
  240. access_check.jsonapi.relationship_field_access:
  241. # Deprecated in drupal:9.2.0 and is removed from drupal:10.0.0. There is no
  242. # replacement. JSON:API's access checkers are not part of its public API.
  243. # See https://www.drupal.org/node/3194641.
  244. class: Drupal\jsonapi\Access\RelationshipFieldAccess
  245. arguments: ['@jsonapi.entity_access_checker']
  246. tags:
  247. - { name: access_check, applies_to: _jsonapi_relationship_field_access, needs_incoming_request: TRUE }

Services

Namesort descending Description
access_check.jsonapi.relationship_field_access Drupal\jsonapi\Access\RelationshipFieldAccess
access_check.jsonapi.relationship_route_access Drupal\jsonapi\Access\RelationshipRouteAccessCheck
cache.jsonapi_memory Drupal\Core\Cache\MemoryCache\MemoryCache
cache.jsonapi_normalizations Drupal\Core\Cache\CacheBackendInterface
cache.jsonapi_resource_types Drupal\Core\Cache\BackendChain
jsonapi.custom_query_parameter_names_validator.subscriber Drupal\jsonapi\EventSubscriber\JsonApiRequestValidator
jsonapi.entity_access_checker Drupal\jsonapi\Access\EntityAccessChecker
jsonapi.entity_resource Drupal\jsonapi\Controller\EntityResource
jsonapi.exception_subscriber Drupal\jsonapi\EventSubscriber\DefaultExceptionSubscriber
jsonapi.field_resolver Drupal\jsonapi\Context\FieldResolver
jsonapi.file.uploader.field Drupal\jsonapi\Controller\TemporaryJsonapiFileFieldUploader
jsonapi.file_upload Drupal\jsonapi\Controller\FileUpload
jsonapi.include_resolver Drupal\jsonapi\IncludeResolver
jsonapi.normalization_cacher Drupal\jsonapi\EventSubscriber\ResourceObjectNormalizationCacher
jsonapi.resource_response.subscriber Drupal\jsonapi\EventSubscriber\ResourceResponseSubscriber
jsonapi.resource_response_validator.subscriber Drupal\jsonapi\EventSubscriber\ResourceResponseValidator
jsonapi.resource_type.repository Drupal\jsonapi\ResourceType\ResourceTypeRepository
jsonapi.resource_version.route_enhancer Drupal\jsonapi\Revisions\ResourceVersionRouteEnhancer
jsonapi.route_enhancer Drupal\jsonapi\Routing\RouteEnhancer
jsonapi.route_filter.format_setter Drupal\jsonapi\Routing\EarlyFormatSetter
jsonapi.serializer Drupal\jsonapi\Serializer\Serializer
jsonapi.version_negotiator Drupal\jsonapi\Revisions\VersionNegotiator
jsonapi.version_negotiator.default Abstract
jsonapi.version_negotiator.id Drupal\jsonapi\Revisions\VersionById
jsonapi.version_negotiator.rel Drupal\jsonapi\Revisions\VersionByRel
logger.channel.jsonapi
method_filter.jsonapi Drupal\jsonapi\Routing\ReadOnlyModeMethodFilter
paramconverter.jsonapi.entity_uuid Drupal\jsonapi\ParamConverter\EntityUuidConverter
paramconverter.jsonapi.resource_type Drupal\jsonapi\ParamConverter\ResourceTypeConverter
serializer.encoder.jsonapi Drupal\jsonapi\Encoder\JsonEncoder
serializer.normalizer.config_entity.jsonapi Drupal\jsonapi\Normalizer\ConfigEntityDenormalizer
serializer.normalizer.content_entity.jsonapi Drupal\jsonapi\Normalizer\ContentEntityDenormalizer
serializer.normalizer.data.jsonapi Drupal\jsonapi\Normalizer\DataNormalizer
serializer.normalizer.entity_access_exception.jsonapi Drupal\jsonapi\Normalizer\EntityAccessDeniedHttpExceptionNormalizer
serializer.normalizer.field.jsonapi Drupal\jsonapi\Normalizer\FieldNormalizer
serializer.normalizer.field_item.jsonapi Drupal\jsonapi\Normalizer\FieldItemNormalizer
serializer.normalizer.http_exception.jsonapi Drupal\jsonapi\Normalizer\HttpExceptionNormalizer
serializer.normalizer.jsonapi_document_toplevel.jsonapi Drupal\jsonapi\Normalizer\JsonApiDocumentTopLevelNormalizer
serializer.normalizer.link_collection.jsonapi Drupal\jsonapi\Normalizer\LinkCollectionNormalizer
serializer.normalizer.relationship.jsonapi Drupal\jsonapi\Normalizer\RelationshipNormalizer
serializer.normalizer.resource_identifier.jsonapi Drupal\jsonapi\Normalizer\ResourceIdentifierNormalizer
serializer.normalizer.resource_object.jsonapi Drupal\jsonapi\Normalizer\ResourceObjectNormalizer
serializer.normalizer.unprocessable_entity_exception.jsonapi Drupal\jsonapi\Normalizer\UnprocessableHttpEntityExceptionNormalizer