services:
  _defaults:
    autowire: true
    autoconfigure: true
    bind:
      $projectDir: '%kernel.project_dir%'

  AutoAdmin\Bundle\Media\Admin\Form\TypeGuesser\:
    resource: '../../Admin/Form/TypeGuesser'
    tags:
      - { name: 'aa_admin.type_guesser' }

  AutoAdmin\Bundle\Media\Form\Type\FileType:
    arguments:
      - '%aa_media_config%'
      - '@doctrine'
      - '@AutoAdmin\Bundle\Core\Util\SizeConverter'
    tags:
      - { name: form.type }

  AutoAdmin\Bundle\Media\Form\Type\ImageType:
    arguments:
      - '%aa_media_config%'
      - '@doctrine'
    tags:
      - { name: form.type }

  AutoAdmin\Bundle\Media\Upload\UploadHandler:
    arguments:
      - '@AutoAdmin\Bundle\Media\Mapper\MapperManager'
      - '@AutoAdmin\Bundle\Media\Namer\NamerInterface'
      - '@Symfony\Component\Filesystem\Filesystem'
      - '%aa_media_config%'
      - '@AutoAdmin\Bundle\Core\Upload\FileVerifier'

  aa_media.listener.upload:
    class: 'AutoAdmin\Bundle\Media\EventListener\Doctrine\UploadListener'
    arguments:
      - '@AutoAdmin\Bundle\Media\Upload\UploadHandler'
    #    parent: 'aa_media.listener.doctrine.base'
    tags:
      - { name: 'doctrine.event_listener', event: 'prePersist' }
      - { name: 'doctrine.event_listener', event: 'preUpdate' }

  aa_media.listener.remove:
    class: 'AutoAdmin\Bundle\Media\EventListener\Doctrine\RemoveListener'
    arguments: [ '@AutoAdmin\Bundle\Media\Upload\UploadHandler' ]
    tags:
      - { name: 'doctrine.event_listener', event: 'preRemove' }
      - { name: 'doctrine.event_listener', event: 'postRemove' }

  AutoAdmin\Bundle\Media\Mapper\MapperManager:
    arguments:
      - !tagged_iterator aa_media.mapper

  AutoAdmin\Bundle\Media\Mapper\TypedFileMapper:
    arguments:
      $mapperConfig: null # replaced in MapperConfigPass
    tags:
      - aa_media.mapper

  AutoAdmin\Bundle\Media\Namer\NamerInterface:
    class: AutoAdmin\Bundle\Media\Namer\DefaultNamer
    arguments:
      - '@AutoAdmin\Bundle\Core\Slugger\Slugger'

  #    AutoAdmin\Bundle\Media\Repository\FileRepository:
  #        arguments: [ '@doctrine' ]
  #        tags:
  #            - 'doctrine.repository_service'
  #
  #    AutoAdmin\Bundle\Media\Repository\ImageRepository:
  #        arguments: [ '@doctrine' ]
  #        tags:
  #            - 'doctrine.repository_service'

  AutoAdmin\Bundle\Media\Service\PublicPathGenerator:
    arguments:
      - '@AutoAdmin\Bundle\Media\Mapper\MapperManager'
      - '@liip_imagine.service.filter'

  AutoAdmin\Bundle\Media\Service\MediaCacheCleaner:
    arguments:
      - '@liip_imagine.cache.manager'

  AutoAdmin\Bundle\Media\Twig\Extension\MediaExtension:
    arguments:
      - '@AutoAdmin\Bundle\Media\Service\PublicPathGenerator'
    tags:
      - { name: 'twig.extension' }

  AutoAdmin\Bundle\Media\Service\MediaManipulator:
    arguments:
      - '@AutoAdmin\Bundle\Admin\Factory\ContentFactory'
      - '@AutoAdmin\Bundle\Media\Namer\NamerInterface'
      - '@AutoAdmin\Bundle\Media\Mapper\MapperManager'
      - '@Symfony\Component\Filesystem\Filesystem'

  AutoAdmin\Bundle\Media\Admin\Controller\:
    resource: '../../Admin/Controller/*Controller.php'
    exclude: '../../Admin/Controller/{Traits}'
    tags:
      - 'aa_admin.controller'

  AutoAdmin\Bundle\Media\Repository\ImageMediaRepository:
    tags:
      - 'aa_content.repository'

  AutoAdmin\Bundle\Media\Repository\FileMediaRepository:
    tags:
      - 'aa_content.repository'

  AutoAdmin\Bundle\Media\Repository\PrivateImageMediaRepository:
    tags:
      - 'aa_content.repository'

  AutoAdmin\Bundle\Media\Repository\PrivateFileMediaRepository:
    tags:
      - 'aa_content.repository'

  AutoAdmin\Bundle\Media\Namer\MediaNamer:
    arguments:
      - '@AutoAdmin\Bundle\Core\Slugger\Slugger'

  AutoAdmin\Bundle\Media\Upload\MediaUploadHandler: ~
  AutoAdmin\Bundle\Media\Upload\MediaRemoveHandler: ~

  AutoAdmin\Bundle\Media\Library\MediaTypeResolver:
    arguments:
      - '%aa_media_config%'
  AutoAdmin\Bundle\Media\Library\MediaPathGenerator: ~
  AutoAdmin\Bundle\Media\Library\PreviewGenerator: ~
  AutoAdmin\Bundle\Media\Library\MediaLibrary: ~
  AutoAdmin\Bundle\Media\Library\MediaFileValidator: ~
  AutoAdmin\Bundle\Media\Library\MediaResolver: ~

  AutoAdmin\Bundle\Media\Form\Type\Media\LinkedMediaType:
    public: true
    arguments:
      - '@AutoAdmin\Bundle\Media\Library\MediaTypeResolver'
      - '@AutoAdmin\Bundle\Media\Library\MediaLibrary'
      - '@AutoAdmin\Bundle\Media\Library\PreviewGenerator'
      - '@AutoAdmin\Bundle\Media\Library\LinkedMediaPropHelper'
    tags:
      - { name: form.type }

  AutoAdmin\Bundle\Media\Serializer\MediaNormalizer:
    arguments:
      - '@serializer.normalizer.object'
    tags:
      - { name: serializer.normalizer }

  AutoAdmin\Bundle\Media\EventListener\Doctrine\MediaRemoveListener:
    tags:
      - { name: 'doctrine.event_listener', event: 'preRemove' }
      - { name: 'doctrine.event_listener', event: 'postRemove' }

  AutoAdmin\Bundle\Media\Library\LinkedMediaPropHelper: ~

  AutoAdmin\Bundle\Media\Admin\Controller\LibraryAdminController:
    arguments:
      $projectDir: '%kernel.project_dir%'
