parameters:
    irstea_file_upload.entity: Irstea\FileUploadBundle\Entity\UploadedFile

    irstea_file_upload.upload_controller.class: Irstea\FileUploadBundle\Controller\UploadController
    irstea_file_upload.entity_listener.class: Irstea\FileUploadBundle\Listener\UploadedFileListener
    irstea_file_upload.field_type.class: Irstea\FileUploadBundle\Form\Type\FileUploadType

    irstea_file_upload.filesystem.name: irstea_file_upload

services:

    # Le gestionnaire de fichiers
    irstea_file_upload.file_manager:
        class: Irstea\FileUploadBundle\Service\FileManagerInterface
        factory:  [ @doctrine.orm.entity_manager, getRepository ]
        arguments:
            - %irstea_file_upload.entity%
        calls:
            - [ setFilesystem, [ @irstea_file_upload.filesystem ] ]
            - [ setLogger, [ @logger ] ]
        tags:
            - { name: monolog.logger, channel: irstea_file_upload }

    # Le contrôleur qui gère les uploads
    irstea_file_upload.upload_controller:
        class: %irstea_file_upload.upload_controller.class%
        arguments:
            - @irstea_file_upload.file_manager
            - @router
            - @form.csrf_provider

    # Type de champ
    irstea_file_upload.field_type:
        class: %irstea_file_upload.field_type.class%
        arguments:
            - @router
            - @irstea_file_upload.file_manager
        tags:
            - { name: form.type, alias: file_upload }

    # Le listener
    irstea_file_upload.entity_listener:
        class: %irstea_file_upload.entity_listener.class%
        arguments:
            - @irstea_file_upload.filesystem
        tags:
            - { name: doctrine.orm.entity_listener }

    # Le backend de stockage des fichiers
    irstea_file_upload.filesystem:
        class: Gaufrette\Filesystem
        factory: [ @knp_gaufrette.filesystem_map, get ]
        arguments:
            - %irstea_file_upload.filesystem.name%
