media_mpx-8.x-1.x-dev/media_mpx.services.yml
media_mpx.services.yml
services:
# This is the service used to make authenticated requests to mpx.
media_mpx.authenticated_client_factory:
class: Drupal\media_mpx\AuthenticatedClientFactory
arguments: ['@media_mpx.client', '@media_mpx.user_session_factory']
media_mpx.data_object_factory_creator:
class: Drupal\media_mpx\DataObjectFactoryCreator
arguments: ['@media_mpx.data_service_manager', '@media_mpx.authenticated_client_factory', '@media_mpx.metadata_cache_pool_adapter']
media_mpx.data_service_manager:
class: Lullabot\Mpx\DataService\DataServiceManager
factory: ['Lullabot\Mpx\DataService\DataServiceManager', 'basicDiscovery']
arguments: ['@media_mpx.custom_field_manager']
media_mpx.user_session_factory:
class: Drupal\media_mpx\UserSessionFactory
arguments: ['@media_mpx.client', '@media_mpx.session_lock', '@media_mpx.token_cache_pool']
media_mpx.data_object_importer:
class: Drupal\media_mpx\DataObjectImporter
arguments: ['@entity_type.manager', '@event_dispatcher', '@cache.media_mpx_http']
media_mpx.notification_listener:
class: Drupal\media_mpx\NotificationListener
arguments: ['@media_mpx.authenticated_client_factory', '@media_mpx.data_service_manager', '@state', '@logger.channel.media_mpx']
logger.channel.media_mpx:
parent: logger.channel_base
arguments: ['media_mpx']
media_mpx.exception_logger:
class: Drupal\media_mpx\MpxLogger
arguments: ['@logger.channel.media_mpx']
# Discovers custom field classes in all enabled modules
media_mpx.custom_field_discovery:
class: Drupal\media_mpx\CustomFieldDiscovery
arguments: ['@container.namespaces']
media_mpx.custom_field_manager:
class: Lullabot\Mpx\DataService\CustomFieldManager
arguments: ['@media_mpx.custom_field_discovery']
# We need to define our own handler stack instance separate from Drupal
# core's. Otherwise, when we add the mpx_errors handler, it gets applied to
# all HTTP requests, and not just those sent to mpx.
media_mpx.http_handler_stack:
class: GuzzleHttp\HandlerStack
public: false
factory: GuzzleHttp\HandlerStack::create
configurator: ['@http_handler_stack_configurator', configure]
media_mpx.http_handler_stack_configurator:
class: Drupal\Core\Http\HandlerStackConfigurator
public: false
arguments: ['@service_container']
# This service is a generic client handling both authenticated and anonymous
# requests. Most code will want to use media_mpx.authenticated_client_factory
# instead.
media_mpx.client:
class: Lullabot\Mpx\Client
factory: media_mpx.client_factory:fromOptions
media_mpx.client_factory:
class: Drupal\media_mpx\ClientFactory
arguments: ['@media_mpx.http_handler_stack', '@http_client_factory', '@cache.media_mpx_http']
# Defines an array or memory cache that supports a limit on the number of
# items.
cache.backend.media_mpx.array_cache_pool:
class: Drupal\media_mpx\ArrayCachePoolFactory
arguments: ['@datetime.time', '@cache_tags.invalidator.checksum', 100]
# Use the above array cache on top of the normal HTTP request cache. We use
# the ChainedFastBackend cache so any invalidations on the consistent cache
# are shared with all threads.
cache.backend.media_mpx.chainedfast_http:
class: Drupal\Core\Cache\ChainedFastBackendFactory
arguments: ['@settings', null, 'cache.backend.media_mpx.array_cache_pool']
calls:
- [setContainer, ['@service_container']]
cache.media_mpx_http:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin , default_backend: cache.backend.media_mpx.chainedfast_http}
factory: cache_factory:get
arguments: [media_mpx_http]
# These services are "internal" and generally not needed by custom code.
media_mpx.session_lock:
class: Lullabot\DrupalSymfonyLock\DrupalStore
public: false
arguments: ['@lock']
# Factory for the \Drupal\Core\Cache\BackendChain class. Core does not ship
# with a factory for this class as it no longer uses this class itself.
# However, for the metadata cache (which holds the information Symfony uses
# to deserialize responses) we do not need a consistent cache since only a
# code change can invalidate the cache. Note that using ChainedFastBackend
# for the metadata cache incurs a significant performance hit, as every
# single call to invalidate cache tags invalidates the whole fast cache.
cache.backend.media_mpx.array_backend_chain:
class: Drupal\media_mpx\ArrayBackendChainFactory
arguments: ['@settings']
calls:
- [setContainer, ['@service_container']]
# The mpx-php library implements PSR-6, but there is only a PSR-16 cache
# adapter for Drupal. We use Symfony to bridge PSR-16 to PSR-6.
cache.media_mpx_metadata:
class: Drupal\Core\Cache\CacheBackendInterface
tags:
- { name: cache.bin, default_backend: cache.backend.media_mpx.array_backend_chain }
factory: cache_factory:get
arguments: [media_mpx_metadata]
media_mpx.simple_cache_backend_default:
class: Drupal\media_mpx\DrupalPSR16\Cache
public: false
arguments: ['@cache.default', '@datetime.time']
media_mpx.simple_cache_backend_metadata:
class: Drupal\media_mpx\DrupalPSR16\Cache
public: false
arguments: ['@cache.media_mpx_metadata', '@datetime.time']
media_mpx.token_cache_pool_adapter:
class: Symfony\Component\Cache\Adapter\Psr16Adapter
public: false
arguments: ['@media_mpx.simple_cache_backend_default', 'media_mpx_token']
media_mpx.metadata_cache_pool_adapter:
class: Symfony\Component\Cache\Adapter\Psr16Adapter
public: false
arguments: ['@media_mpx.simple_cache_backend_metadata', 'media_mpx_metadata']
media_mpx.token_cache_pool:
class: Lullabot\Mpx\TokenCachePool
public: false
arguments: ['@media_mpx.token_cache_pool_adapter']
media_mpx.event_subscriber:
class: Drupal\media_mpx\EventSubscriber\MediaMpxSubscriber
arguments: ['@messenger']
tags:
- { name: event_subscriber }
media_mpx.media_available_access:
class: Drupal\media_mpx\Access\MediaAvailableAccess
arguments: ['@datetime.time']
media_mpx.repository.mpx_media_types:
class: Drupal\media_mpx\Repository\MpxMediaType
arguments: ['@entity_type.manager']
media_mpx.service.queue_video_imports:
class: Drupal\media_mpx\Service\QueueVideoImports
arguments:
- '@media_mpx.repository.mpx_media_types'
- '@logger.channel.media_mpx'
- '@event_dispatcher'
- '@media_mpx.data_object_factory_creator'
- '@queue'
media_mpx.service.update_video_item:
class: Drupal\media_mpx\Service\UpdateVideoItem\UpdateVideoItem
arguments:
- '@media_mpx.repository.mpx_media_types'
- '@media_mpx.data_object_importer'
- '@media_mpx.data_object_factory_creator'
media_mpx.availability_summary:
class: Drupal\media_mpx\DateTime\AvailabilitySummary
arguments: ['@datetime.time', '@date.formatter']
