parameters:
    kunstmaan_media.media_manager.class: 'Kunstmaan\MediaBundle\Helper\MediaManager'
    kunstmaan_media.folder_manager.class: 'Kunstmaan\MediaBundle\Helper\FolderManager'
    kunstmaan_media.menu.adaptor.class: 'Kunstmaan\MediaBundle\Helper\Menu\MediaMenuAdaptor'
    kunstmaan_media.listener.doctrine.class: 'Kunstmaan\MediaBundle\EventListener\DoctrineMediaListener'
    kunstmaan_media.form.type.media.class: 'Kunstmaan\MediaBundle\Form\Type\MediaType'
    kunstmaan_media.form.type.iconfont.class: 'Kunstmaan\MediaBundle\Form\Type\IconFontType'
    kunstmaan_media.icon_font_manager.class: 'Kunstmaan\MediaBundle\Helper\IconFont\IconFontManager'
    kunstmaan_media.icon_font.default_loader.class: 'Kunstmaan\MediaBundle\Helper\IconFont\DefaultIconFontLoader'
    kunstmaan_media.media_creator_service.class: 'Kunstmaan\MediaBundle\Helper\Services\MediaCreatorService'
    kunstmaan_media.mimetype_guesser.factory.class: 'Kunstmaan\MediaBundle\Helper\MimeTypeGuesserFactory'
    kunstmaan_media.extension_guesser.factory.class: 'Kunstmaan\MediaBundle\Helper\ExtensionGuesserFactory'
    kunstmaan_media.validator.has_guessable_extension.class: 'Kunstmaan\MediaBundle\Validator\Constraints\HasGuessableExtensionValidator'

services:
    # Autowire aliases
    Kunstmaan\MediaBundle\Helper\MediaManager: '@kunstmaan_media.media_manager'

    kunstmaan_media.media_manager:
        class: '%kunstmaan_media.media_manager.class%'
        calls:
            - [ setDefaultHandler, [ '@kunstmaan_media.media_handlers.file' ] ]
        public: true

    kunstmaan_media.listener.doctrine:
        class: '%kunstmaan_media.listener.doctrine.class%'
        arguments: ['@kunstmaan_media.media_manager']
        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' }
            - { name: 'doctrine.event_listener', event: 'preRemove' }

    form.type.media:
        class: '%kunstmaan_media.form.type.media.class%'
        arguments:
            - '@kunstmaan_media.media_manager'
            - '@doctrine.orm.entity_manager'
        tags:
            - { name: form.type}

    form.type.iconfont:
        class: '%kunstmaan_media.form.type.iconfont.class%'
        arguments: ['@kunstmaan_media.icon_font_manager']
        tags:
            - { name: form.type }

    kunstmaan_media.icon_font_manager:
        class: '%kunstmaan_media.icon_font_manager.class%'
        calls:
            - [ setDefaultLoader, [ '@kunstmaan_media.icon_font.default_loader' ] ]

    kunstmaan_media.icon_font.default_loader:
        class: '%kunstmaan_media.icon_font.default_loader.class%'
        arguments: ['@kernel']
        tags:
            -  { name: 'kunstmaan_media.icon_font.loader' }

    kunstmaan_media.media_creator_service:
        class: '%kunstmaan_media.media_creator_service.class%'
        arguments: ['@service_container']
        public: true

    kunstmaan_media.repository.folder:
        class:            Kunstmaan\MediaBundle\Repository\FolderRepository
        factory:          ['@doctrine.orm.entity_manager', getRepository]
        arguments:        ['KunstmaanMediaBundle:Folder']

    kunstmaan_media.menu.adaptor:
        class: '%kunstmaan_media.menu.adaptor.class%'
        arguments: ['@kunstmaan_media.repository.folder']
        tags:
            -  { name: 'kunstmaan_admin.menu.adaptor', priority: 150  }

    kunstmaan_media.folder_manager:
        class: '%kunstmaan_media.folder_manager.class%'
        arguments: ['@kunstmaan_media.repository.folder']
        public: true

    kunstmaan_media.mimetype_guesser.factory:
        class: '%kunstmaan_media.mimetype_guesser.factory.class%'

    kunstmaan_media.extension_guesser.factory:
        class: '%kunstmaan_media.extension_guesser.factory.class%'

    kunstmaan_media.command.rebuildfoldertree:
        class: Kunstmaan\MediaBundle\Command\RebuildFolderTreeCommand
        arguments:
            - '@doctrine.orm.entity_manager'
        calls:
            - [setContainer, ['@service_container'] ]
        tags:
            - { name: console.command }

    kunstmaan_media.command.cleandeletedmedia:
        class: Kunstmaan\MediaBundle\Command\CleanDeletedMediaCommand
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@kunstmaan_media.media_manager'
        calls:
            - [setContainer, ['@service_container'] ]
        tags:
            - { name: console.command }

    kunstmaan_media.command.renamesoftdeleted:
        class: Kunstmaan\MediaBundle\Command\RenameSoftDeletedCommand
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@kunstmaan_media.media_manager'
        tags:
            - { name: console.command }

    kunstmaan_media.filesystem_adapter:
        class: Gaufrette\Adapter\Local
        arguments:
            - '%kunstmaan_media.full_media_path%'
            - true

    kunstmaan_media.filesystem:
        class: Gaufrette\Filesystem
        arguments:
            - '@kunstmaan_media.filesystem_adapter'

    kunstmaan_media.validator.has_guessable_extension:
        class: '%kunstmaan_media.validator.has_guessable_extension.class%'
        arguments: ['@mime_types']
        tags:
            - { name: validator.constraint_validator, alias: has_guessable_extension }

    kunstmaan_media.imagine.filter.loader.background:
        class: '%liip_imagine.filter.loader.background.class%'
        arguments:
            - '@liip_imagine'
        tags:
            - { name: 'liip_imagine.filter.loader', loader: 'background' }

    Kunstmaan\MediaBundle\Helper\Imagine\ImagineController:
        arguments:
            - '@liip_imagine.service.filter'
            - '@liip_imagine.data.manager'
            - '@liip_imagine.cache.signer'
            - '@liip_imagine.controller.config'
        tags:
            - { name: 'controller.service_arguments' }
        public: true

    Kunstmaan\MediaBundle\Helper\Imagine\WebPathResolver:
        arguments:
            - '@filesystem'
            - '@router.request_context'
            - ~ # will be injected by WebPathResolverFactory
            - ~ # will be injected by WebPathResolverFactory
            - '@liip_imagine.filter.configuration'
        public: true
        abstract: true

    Kunstmaan\MediaBundle\Helper\Imagine\CacheManager:
        arguments:
            - '@liip_imagine.filter.configuration'
            - '@router'
            - '@liip_imagine.cache.signer'
            - '@event_dispatcher'
            - '%liip_imagine.cache.resolver.default%'

    Gedmo\Tree\TreeListener:
        tags:
            - { name: doctrine.event_subscriber, connection: default }
        calls:
            - [ setAnnotationReader, [ "@annotation_reader" ] ]

    Kunstmaan\MediaBundle\DataFixtures\ORM\FolderFixtures:
        tags:
            - { name: doctrine.fixture.orm }
