wotapi-8.x-1.x-dev/wotapi.services.yml
wotapi.services.yml
parameters:
wotapi.base_path: /wotapi
services:
wotapi.serializer:
class: Drupal\wotapi\Serializer\Serializer
calls:
- [setFallbackNormalizer, ['@serializer']]
arguments: [{ }, { }]
serializer.normalizer.http_exception.wotapi:
class: Drupal\wotapi\Normalizer\HttpExceptionNormalizer
arguments: ['@current_user']
tags:
- { name: wotapi_normalizer }
serializer.normalizer.unprocessable_entity_exception.wotapi:
class: Drupal\wotapi\Normalizer\UnprocessableHttpEntityExceptionNormalizer
arguments: ['@current_user']
tags:
# This must have a higher priority than the 'serializer.normalizer.http_exception.wotapi' to take effect.
- { name: wotapi_normalizer, priority: 1 }
serializer.normalizer.entity_access_exception.wotapi:
class: Drupal\wotapi\Normalizer\EntityAccessDeniedHttpExceptionNormalizer
arguments: ['@current_user']
tags:
# This must have a higher priority than the 'serializer.normalizer.http_exception.wotapi' to take effect.
- { name: wotapi_normalizer, priority: 1 }
serializer.normalizer.field_item.wotapi:
class: Drupal\wotapi\Normalizer\FieldItemNormalizer
arguments: ['@entity_type.manager']
tags:
- { name: wotapi_normalizer }
serializer.normalizer.field.wotapi:
class: Drupal\wotapi\Normalizer\FieldNormalizer
tags:
- { name: wotapi_normalizer }
serializer.normalizer.resource_identifier.wotapi:
class: Drupal\wotapi\Normalizer\ResourceIdentifierNormalizer
arguments: ['@entity_field.manager']
tags:
- { name: wotapi_normalizer }
serializer.normalizer.resource_object.wotapi:
class: Drupal\wotapi\Normalizer\ResourceObjectNormalizer
tags:
- { name: wotapi_normalizer }
serializer.normalizer.wotapi_document_toplevel.wotapi:
class: Drupal\wotapi\Normalizer\WotApiDocumentTopLevelNormalizer
arguments: ['@entity_type.manager', '@wotapi.resource_type.repository']
tags:
- { name: wotapi_normalizer }
serializer.normalizer.link_collection.wotapi:
class: Drupal\wotapi\Normalizer\LinkCollectionNormalizer
tags:
- { name: wotapi_normalizer }
serializer.normalizer.propertytes_field.wotapi:
class: Drupal\wotapi\Normalizer\PropertiesFieldNormalizer
tags:
# This must have a higher priority than the 'serializer.normalizer.field.wotapi' to take effect.
- { name: wotapi_normalizer, priority: 1 }
serializer.encoder.wotapi:
class: Drupal\wotapi\Encoder\JsonEncoder
tags:
- { name: wotapi_encoder, format: 'api_json' }
wotapi.resource_type.repository:
class: Drupal\wotapi\ResourceType\ResourceTypeRepository
arguments: ['@entity_type.manager', '@entity_type.bundle.info', '@entity_field.manager', '@cache.jsonapi_resource_types', '@event_dispatcher']
wotapi.route_enhancer:
class: Drupal\wotapi\Routing\RouteEnhancer
tags:
- { name: route_enhancer }
wotapi.field_resolver:
class: Drupal\wotapi\Context\FieldResolver
arguments: ['@entity_type.manager', '@entity_field.manager', '@entity_type.bundle.info', '@wotapi.resource_type.repository', '@module_handler']
paramconverter.wotapi.entity_uuid:
parent: paramconverter.entity
class: Drupal\wotapi\ParamConverter\EntityUuidConverter
calls:
- [setLanguageManager, ['@language_manager']]
tags:
# Priority 10, to ensure it runs before @paramconverter.entity.
- { name: paramconverter, priority: 10 }
paramconverter.wotapi.resource_type:
class: Drupal\wotapi\ParamConverter\ResourceTypeConverter
arguments: ['@wotapi.resource_type.repository']
tags:
- { name: paramconverter }
wotapi.exception_subscriber:
class: Drupal\wotapi\EventSubscriber\DefaultExceptionSubscriber
tags:
- { name: event_subscriber }
arguments: ['@wotapi.serializer', '%serializer.formats%']
logger.channel.wotapi:
parent: logger.channel_base
arguments: ['wotapi']
# Cache.
cache.wotapi_resource_types:
class: Drupal\Core\Cache\MemoryCache\MemoryCache
# We need this to add this to the Drupal's cache_tags.invalidator service.
# This way it can invalidate the data in here based on tags.
tags: [{ name: cache.bin }]
# Route filter.
wotapi.route_filter.format_setter:
class: Drupal\wotapi\Routing\EarlyFormatSetter
tags:
# Set to a high priority so it runs before content_type_header_matcher
# and other filters that might throw exceptions.
- { name: route_filter, priority: 100 }
# Access Control
wotapi.entity_access_checker:
class: Drupal\wotapi\Access\EntityAccessChecker
public: false
arguments: ['@wotapi.resource_type.repository', '@router.no_access_checks', '@current_user', '@entity.repository']
calls:
# This is a temporary measure. WOT:API should not need to be aware of the Content Moderation module.
- [setLatestRevisionCheck, ['@?access_check.latest_revision']] # This is only injected when the service is available.
# access_check.wotapi.relationship_route_access:
# class: Drupal\wotapi\Access\RelationshipRouteAccessCheck
# arguments: ['@wotapi.entity_access_checker']
# tags:
# - { name: access_check, applies_to: _jsonapi_relationship_route_access }
access_check.wotapi.relationship_field_access:
class: Drupal\wotapi\Access\RelationshipFieldAccess
arguments: ['@wotapi.entity_access_checker']
tags:
- { name: access_check, applies_to: _wotapi_relationship_field_access, needs_incoming_request: TRUE }
# Controller.
wotapi.entity_resource:
class: Drupal\wotapi\Controller\EntityResource
arguments:
- '@entity_type.manager'
- '@entity_field.manager'
- '@wotapi.resource_type.repository'
- '@renderer'
- '@entity.repository'
- '@wotapi.entity_access_checker'
- '@wotapi.field_resolver'
- '@wotapi.serializer'
- '@datetime.time'
- '@current_user'
# Event subscribers.
wotapi.custom_query_parameter_names_validator.subscriber:
class: Drupal\wotapi\EventSubscriber\WotApiRequestValidator
tags:
- { name: event_subscriber }
wotapi.resource_response.subscriber:
class: Drupal\wotapi\EventSubscriber\ResourceResponseSubscriber
arguments: ['@wotapi.serializer']
tags:
- { name: event_subscriber }
# Deprecated services.
serializer.normalizer.htt_exception.wotapi:
alias: serializer.normalizer.http_exception.wotapi
deprecated: The "%alias_id%" service is deprecated. You should use the 'serializer.normalizer.http_exception.wotapi' service instead.
# Thing action services.
plugin.manager.wotapi_action:
parent: default_plugin_manager
class: Drupal\wotapi\Plugin\WotapiActionManager
public: false
wotapi_action.handler:
class: Drupal\wotapi\Handler
arguments: ['@plugin.manager.wotapi_action']
wotapi_action.schema_validator:
class: JsonSchema\Validator
serializer.normalizer.wotapi_action_annotation:
class: Drupal\wotapi\Normalizer\AnnotationNormalizer
public: false
tags:
- { name: normalizer }
