# 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:
    ns.color_admin.menu_builder: App\Menu\MenuBuilder
    system_roles:
        - { role: ROLE_USER, label: Pavilion Admin }
        - { role: ROLE_ADMIN, label: System Admin }

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.
        bind:
            $email_sender: '%env(EMAIL_SENDER)%'
            $email_recipient: '%env(EMAIL_RECIPIENT)%'
            $user_upload_dir: '%kernel.project_dir%/%env(USER_UPLOAD_DIR)%'

    # 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']

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones

    App\Security\SecurityUserProvider:
        public: true

    App\Handler\:
        resource: '../src/Handler/*'
        public: true
        tags: ['command_handler']

    App\Listener\PasswordResetListener:
        tags:
            - { name: kernel.event_listener, event: user.password_reset }

    App\Listener\AdminRouteListener:
        tags:
            - { name: kernel.event_listener, event: kernel.request, priority: -10 }

    App\Form\RoleType:
        arguments: { $system_roles: '%system_roles%'}

    ns.color_admin.menu_builder:
        class: "%ns.color_admin.menu_builder%"
        arguments: ["@knp_menu.factory"]
        tags:
            - { name: knp_menu.menu_builder, method: createSidebarMenu, alias: sidebar } # The alias is what is used to retrieve the menu
            - { name: knp_menu.menu_builder, method: createSidebarMenu, alias: breadcrumbs }
            - { name: knp_menu.menu_builder, method: createPavilionMenu, alias: pavilion_sidebar }
            - { name: knp_menu.menu_builder, method: createDocumentsMenu, alias: documents_sidebar }

    App\Namer\UploadDirectoryNamer:
        public: true

    App\Namer\ImageDirectoryNamer:
        public: true

    App\Namer\PassportImageDirectoryNamer:
        public: true

    App\Namer\ProfilenameNamer:
        public: true

    App\Listener\MailListener:
        tags:
            - { name: doctrine.event_listener, event: prePersist }
            - { name: doctrine.event_listener, event: preUpdate }

    App\Listener\LoginListener:
        tags:
            - { name: kernel.event_listener, event: security.interactive_login }

    App\Listener\ImagineSubscriber:
        arguments: ["%kernel.root_dir%"]
