parameters:
    oro_attachment.manager.attachment_manager.class:             Oro\Bundle\AttachmentBundle\Manager\AttachmentManager
    oro_attachment.listener.file_listener.class:                 Oro\Bundle\AttachmentBundle\EventListener\FileListener

    oro_attachment.entity.class:                                 Oro\Bundle\AttachmentBundle\Entity\Attachment
    oro_attachment.file.entity.class:                            Oro\Bundle\AttachmentBundle\Entity\File
    oro_attachment.manager.api.class:                            Oro\Bundle\AttachmentBundle\Entity\Manager\AttachmentApiEntityManager
    oro_attachment.manager.file.api.class:                       Oro\Bundle\AttachmentBundle\Entity\Manager\FileApiEntityManager

    oro_attachment.twig.file_extension.class:                    Oro\Bundle\AttachmentBundle\Twig\FileExtension

    oro_attachment.entity_config_dumper.extension.file.class:    Oro\Bundle\AttachmentBundle\Tools\FileEntityConfigDumperExtension
    oro_attachment.entity_config_dumper.extension.class:         Oro\Bundle\AttachmentBundle\Tools\AttachmentConfigDumperExtension
    oro_attachment.entity_generator.extension.class:             Oro\Bundle\AttachmentBundle\Tools\AttachmentEntityGeneratorExtension
    oro_attachment.migration.extension.attachment.class:         Oro\Bundle\AttachmentBundle\Migration\Extension\AttachmentExtension

    oro_attachment.serializer.file_normalizer.class:             Oro\Bundle\AttachmentBundle\ImportExport\FileNormalizer

    oro_attachment.placeholder.filter.class:                     Oro\Bundle\AttachmentBundle\Placeholder\PlaceholderFilter
    oro_attachment.attachment_grid_listener:                     Oro\Bundle\AttachmentBundle\EventListener\AttachmentGridListener

    oro_attachment.datagrid.action.dialog.class:                 Oro\Bundle\AttachmentBundle\DataGrid\Action\DialogAction

    oro_attachment.provider.attachment.class:                    Oro\Bundle\AttachmentBundle\Provider\AttachmentProvider
    oro_attachment.config.class:                                 Oro\Bundle\AttachmentBundle\EntityConfig\AttachmentConfig

    oro_attachment.formatter.image_encoded.class:                Oro\Bundle\AttachmentBundle\Formatter\ImageEncodedFormatter
    oro_attachment.formatter.image_link.class:                   Oro\Bundle\AttachmentBundle\Formatter\ImageLinkFormatter
    oro_attachment.formatter.image_src.class:                    Oro\Bundle\AttachmentBundle\Formatter\ImageSrcFormatter

    oro_attachment.attachments_dir:                              attachment
    oro_attachment.imagine.cache.resolver.custom_web_path.name:  custom_web_path

services:
    oro_attachment.manager:
        class: %oro_attachment.manager.attachment_manager.class%
        arguments:
            - '@router'
            - %oro_attachment.files%
            - '@oro_entity_extend.association_manager'
        calls:
            - [setFileManager, ['@oro_attachment.file_manager']]

    oro_attachment.file_manager:
        class: Oro\Bundle\AttachmentBundle\Manager\FileManager
        arguments:
          - '@knp_gaufrette.filesystem_map'

    oro_attachment.image_factory:
        class: Oro\Bundle\AttachmentBundle\Tools\ImageFactory
        arguments:
          - '@liip_imagine.filter.manager'
          - '@liip_imagine.binary.mime_type_guesser'
          - '@liip_imagine.extension_guesser'

    oro_attachment.thumbnail_factory:
        class: Oro\Bundle\AttachmentBundle\Tools\ThumbnailFactory
        arguments:
          - '@oro_attachment.image_factory'
          - '@liip_imagine.filter.configuration'

    oro_attachment.association_helper:
        class: Oro\Bundle\AttachmentBundle\Tools\AttachmentAssociationHelper
        public: false
        arguments:
            - '@oro_entity_config.config_manager'

    oro_attachment.manager.api:
        class: %oro_attachment.manager.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_attachment.entity.class%
            - '@doctrine.orm.entity_manager'
            - '@oro_security.security_facade'
            - '@oro_attachment.manager'
            - '@oro_entity.doctrine_helper'

    oro_attachment.manager.file.api:
        class: %oro_attachment.manager.file.api.class%
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - %oro_attachment.file.entity.class%
            - '@doctrine.orm.entity_manager'
            - '@oro_security.security_facade'
            - '@oro_attachment.file_manager'
            - '@oro_attachment.manager'

    oro_attachment.listener.file_listener:
        class: %oro_attachment.listener.file_listener.class%
        arguments:
            - '@oro_attachment.file_manager'
            - '@oro_security.security_facade.link'
        tags:
            - { name: doctrine.event_listener, event: prePersist }
            - { name: doctrine.event_listener, event: preUpdate }
            - { name: doctrine.event_listener, event: postPersist }
            - { name: doctrine.event_listener, event: postUpdate }

    oro_attachment.twig.file_extension:
        class: %oro_attachment.twig.file_extension.class%
        arguments: ['@oro_attachment.manager', '@oro_entity_config.config_manager', '@doctrine']
        tags:
            - { name: twig.extension }

    oro_attachment.entity_config_dumper.extension.file:
        class: %oro_attachment.entity_config_dumper.extension.file.class%
        arguments:
            - '@oro_entity_config.config_manager'
            - '@oro_entity_extend.relation_builder'
        tags:
            - { name: oro_entity_extend.entity_config_dumper_extension }

    oro_attachment.entity_config_dumper.extension:
        class: %oro_attachment.entity_config_dumper.extension.class%
        parent: oro_entity_extend.entity_config_dumper.extension.association
        tags:
            - { name: oro_entity_extend.entity_config_dumper_extension }

    oro_attachment.entity_generator.extension:
        class: %oro_attachment.entity_generator.extension.class%
        tags:
            - { name: oro_entity_extend.entity_generator_extension }


    oro_attachment.migration.extension.attachment:
        class: %oro_attachment.migration.extension.attachment.class%
        tags:
            - { name: oro_migration.extension, extension_name: attachment }

    oro_attachment.serializer.file_normalizer:
        class: %oro_attachment.serializer.file_normalizer.class%
        calls:
            - [setAttachmentManager, ['@oro_attachment.manager']]
            - [setFileManager, ['@oro_attachment.file_manager']]
            - [setValidator, ['@oro_attachment.validator.file_config_validator']]
        tags:
            - { name: oro_importexport.normalizer}

    oro_attachment.placeholder.filter:
        class: %oro_attachment.placeholder.filter.class%
        arguments:
            - '@oro_attachment.association_helper'
            - '@oro_entity.doctrine_helper'

    oro_attachment.event_listener.attachment_grid_listener:
        class: %oro_attachment.attachment_grid_listener%
        arguments:
            - [entityId]
        tags:
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.after.attachment-grid, method: onBuildAfter }
            - { name: kernel.event_listener, event: oro_datagrid.datagrid.build.before.attachment-grid, method: onBuildBefore }

    oro_attachment.listener.merge_listener:
        class: Oro\Bundle\AttachmentBundle\EventListener\MergeListener
        arguments:
            - '@oro_attachment.manager'
        tags:
            - { name: kernel.event_listener, event: oro.entity_merge.build_metadata, method: onBuildMetadata }

    oro_attachment.datagrid.action.dialog:
        class: %oro_attachment.datagrid.action.dialog.class%
        scope: prototype
        tags:
            - { name: oro_datagrid.extension.action.type, type: dialog }

    oro_attachment.widget_provider.actions:
        parent: oro_ui.widget_provider.action_button.abstract
        arguments:
            - oro_add_attachment_button
            - oro_add_attachment_link
        tags:
            - { name: oro_ui.view_action_provider, group: activity, priority: -90 }
            - { name: oro_ui.update_action_provider, group: activity, priority: -90 }

    oro_attachment.provider.attachment:
        class: %oro_attachment.provider.attachment.class%
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_attachment.association_helper'
            - '@oro_attachment.manager'

    oro_attachment.exclusion_provider:
        class: Oro\Bundle\AttachmentBundle\Provider\AttachmentExclusionProvider
        public: false
        tags:
            - { name: oro_entity.exclusion_provider.api }

    oro_attachment.config:
        class: %oro_attachment.config.class%
        arguments:
            - '@oro_attachment.association_helper'

    oro_attachment.formatter.image_encoded:
        class: %oro_attachment.formatter.image_encoded.class%
        arguments:
          - '@oro_attachment.file_manager'
          - '@file_locator'
        tags:
          - { name: oro_formatter, formatter: image_encoded }

    oro_attachment.formatter.image_link:
        class: %oro_attachment.formatter.image_link.class%
        arguments:
          - '@oro_attachment.manager'
          - '@translator'
        tags:
          - { name: oro_formatter, formatter: image_link }

    oro_attachment.formatter.image_src:
        class: %oro_attachment.formatter.image_src.class%
        arguments:
          - '@oro_attachment.manager'
        tags:
          - { name: oro_formatter, formatter: image_src }

    oro_attachment.imagine.cache.resolver.custom_web_path:
        class: 'Oro\Bundle\AttachmentBundle\Imagine\Cache\Resolver\CustomWebPathResolver'
        arguments:
          - '@filesystem'
          - '@router.request_context'
          - '%kernel.root_dir%/../web'
        tags:
          - { name: liip_imagine.cache.resolver, resolver: %oro_attachment.imagine.cache.resolver.custom_web_path.name% }

    oro_attachment.image_resizer:
        class: 'Oro\Bundle\AttachmentBundle\Resizer\ImageResizer'
        arguments:
            - '@oro_attachment.manager'
            - '@liip_imagine.cache.manager'
            - '@oro_attachment.file_manager'
            - '@oro_attachment.image_factory'
            - '%oro_attachment.imagine.cache.resolver.custom_web_path.name%'
        calls:
            - [setLogger, ['@logger']]
