# This file is the entry point to configure your own services.
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
#parameters:


services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
        # public: true

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    App\:
        resource: '../src/*'
        exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'

    # controllers are imported separately to make sure services can be injected
    # as action arguments even if you don't extend any base controller class
    App\Controller\:
        resource: '../src/Controller'
        tags: ['controller.service_arguments']

    app.main_menu:
        class: Knp\Menu\MenuItem # the service definition requires setting the class
        factory: ["@app.menu_builder", createMainMenu]
        arguments: ["@request_stack"]
        tags:
            - { name: knp_menu.menu, alias: main } # The alias is what is used to retrieve the menu

    App\Form\Extension\EntityTypeExtension:
        arguments: ["@security.token_storage", "@translator", "@doctrine.orm.entity_manager"]
        tags:
            - { name: form.type_extension, extended_type: Symfony\Bridge\Doctrine\Form\Type\EntityType }



    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones
    # app.app_listener:
    #     class: App\Listeners\AppListener
    #     tags:
    #         - { name: doctrine.event_listener, event: postUpdate}

    app.media_object_listener:
        class: App\Listeners\MediaObjectListener
        tags:
            - { name: doctrine.event_listener, event: postUpdate}
            - { name: doctrine.event_listener, event: preRemove}
            - { name: doctrine.event_listener, event: prePersist}
            - { name: doctrine.event_listener, event: preUpdate}
            - { name: kernel.event_listener, event: vich_uploader.pre_inject }
            - { name: kernel.event_listener, event: vich_uploader.post_upload }

    app.web_page_listener:
        class: App\Listeners\WebPageListener
        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: postRemove }

    app.article_listener:
        class: App\Listeners\ArticleListener
        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: postRemove }

    app.accommodation_listener:
        class: App\Listeners\AccommodationListener
        tags:
            - { name: doctrine.event_listener, event: prePersist }
            - { name: doctrine.event_listener, event: postPersist }
            - { name: doctrine.event_listener, event: preUpdate }
            - { name: doctrine.event_listener, event: postRemove }

    app.gallery_listener:
        class: App\Listeners\GalleryListener
        tags:
            - { name: doctrine.event_listener, event: postPersist }
            - { name: doctrine.event_listener, event: postUpdate }
            - { name: doctrine.event_listener, event: preUpdate }
            - { name: doctrine.event_listener, event: onFlush }


    # app.meta_balise_listener:
    #     class: App\Listeners\MetaBaliseListener
    #     tags:
    #         - { name: doctrine.event_listener, event: prePersist }
    #         - { name: doctrine.event_listener, event: preUpdate, priority: 500 }

    app.menu_builder:
        class: App\Service\Menu\Builder
        arguments: ["@doctrine.orm.entity_manager", "@knp_menu.factory"]

    app.billing_calculator:
        class: App\Service\Billing\Calculator
        arguments: ["@doctrine.orm.entity_manager", "@easyadmin.config.manager", "@security.token_storage", "@translator"]
        public: true

    app.billing_numerator:
        class: App\Service\Billing\Numerator
        arguments: ["@doctrine.orm.entity_manager", "@easyadmin.config.manager", "@security.token_storage", "@translator"]
        public: true

    app.translator:
        class: App\Service\Translation\Translator
        arguments: ["@service_container", "@doctrine.orm.entity_manager"]
        public: true

    app.meta_data:
        class: App\Service\SEO\MetaData
        arguments: ["@service_container", "@doctrine.orm.entity_manager"]
        public: true

    app.nuxtjs.router:
        class: App\Service\NuxtJS\Router
        arguments: ["@service_container", "@doctrine.orm.entity_manager"]
        public: true

    app.nuxtjs.build:
        class: App\Service\NuxtJS\Build
        arguments: ["@service_container", "@doctrine.orm.entity_manager", "@mailer", "@twig"]
        public: true

    app.nuxtjs.silence_folder:
        class: App\Service\NuxtJS\SilenceFolder
        arguments: ["@service_container"]
        public: true

    app.nuxtjs.export_json_data:
        class: App\Service\NuxtJS\ExportJsonData
        arguments: ["@service_container", "@doctrine.orm.entity_manager"]
        public: true

    app.nuxtjs.export_pdf_file:
        class: App\Service\NuxtJS\ExportPdfFile
        arguments: ["@service_container", "@doctrine.orm.entity_manager"]
        public: true

    app.export.api_to_json:
        class: App\Service\Export\ApiToJson
        arguments: ["@service_container", "@doctrine.orm.entity_manager"]
        public: true

    app.export.annotation_entity:
        class: App\Service\Export\AnnotationEntity
        arguments: ["@service_container", "@doctrine.orm.entity_manager"]
        public: true

    app.command.console:
        class: App\Service\Command\Console
        arguments: [ "@service_container" ]
        public: true

    app.tools.media:
        class: App\Service\Tools\Media
        # arguments: ["@service_container", "@doctrine.orm.entity_manager"]
        public: true

    app.tools.pdf_builder:
        class: App\Service\Tools\PdfBuilder
        # arguments: ["@service_container", "@doctrine.orm.entity_manager"]
        public: true

    imagine.cache.resolver.custom_cache:
        class: App\Service\Imagine\CustomResolver
        arguments:
            - "@service_container"
            - "@filesystem"
            - "@router.request_context"
            - '%DIRECTORY_RESOURCES%'
            - '%assets.cache_prefix%'
        tags:
            - { name: "liip_imagine.cache.resolver", resolver: custom_cache }

    Liip\ImagineBundle\Service\FilterService:
        alias: 'liip_imagine.service.filter'

    App\EventSubscriber\ApiEventManager:
        arguments: ["@service_container"]

    App\EventSubscriber\CalendarSubscriber:
        # tags:
        #     - { name: 'kernel.event_listener', event: 'fullcalendar.set_data', method: loadEvents }
