parameters:
    ezpublish.core.io.stream_file_listener.class: eZ\Bundle\EzPublishIOBundle\EventListener\StreamFileListener
    ezpublish.core.io.flysystem.default_adapter.class: League\Flysystem\Adapter\Local

services:
    # Builds the binarydata and metadata handler based on the siteaccess config
    ezpublish.core.io.metadata_handler:
        class: eZ\Publish\Core\IO\IOMetadataHandler
        factory_service: ezpublish.core.io.metadata_handler.factory
        factory_method: getConfiguredHandler
        arguments:
            - "$io.metadata_handler$"

    ezpublish.core.io.binarydata_handler:
        class: eZ\Publish\Core\IO\IOBinarydataHandler
        factory_service: ezpublish.core.io.binarydata_handler.factory
        factory_method: getConfiguredHandler
        arguments:
            - "$io.binarydata_handler$"

    ezpublish.core.io.metadata_handler.factory:
        class: eZ\Bundle\EzPublishIOBundle\ApiLoader\HandlerFactory
        calls:
            - [ setContainer, [ @service_container ] ]

    ezpublish.core.io.binarydata_handler.factory:
        class: eZ\Bundle\EzPublishIOBundle\ApiLoader\HandlerFactory
        calls:
            - [ setContainer, [ @service_container ] ]

    # Inject the siteaccess config into a few io services
    ezpublish.core.io.flysystem.default_adapter:
        class: %ezpublish.core.io.flysystem.default_adapter.class%
        arguments:
            - "$io.root_dir$"

    ezpublish.core.io.prefix_url_decorator:
        class: %ezpublish.core.io.url_decorator.absolute_prefix.class%
        calls:
            - [ setPrefix, [ "$io.url_prefix$" ] ]

    # Base service for flysystem metadata handler
    ezpublish.core.io.metadata_handler.flysystem:
        abstract: true
        class: %ezpublish.core.io.binarydata_handler.flysystem.class%
        arguments:
            - ~

    # Default flysystem metadata handler
    ezpublish.core.io.metadata_handler.flysystem.default:
        class: %ezpublish.core.io.metadata_handler.flysystem.class%
        arguments:
            - @ezpublish.core.io.flysystem.default_filesystem

    # Base service for flysystem binarydata handler
    ezpublish.core.io.binarydata_handler.flysystem:
        abstract: true
        class: %ezpublish.core.io.binarydata_handler.flysystem.class%
        arguments:
            - ~
            - @ezpublish.core.io.default_url_decorator

    # Default flysystem binarydata handler
    ezpublish.core.io.binarydata_handler.flysystem.default:
        class: %ezpublish.core.io.binarydata_handler.flysystem.class%
        arguments:
            - @ezpublish.core.io.flysystem.default_filesystem
            - @ezpublish.core.io.default_url_decorator

    ezpublish.core.io.image_fieldtype.legacy_url_decorator:
        class: %ezpublish.core.io.url_decorator.prefix.class%
        calls:
            - [setPrefix, ["$io.legacy_url_prefix$"]]

    ezpublish.core.io.stream_file_listener:
        class: %ezpublish.core.io.stream_file_listener.class%
        arguments:
            - @ezpublish.fieldtype.ezimage.io_service
            - @ezpublish.config.resolver
        tags:
            - { name: kernel.event_subscriber }
