# 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:
    sonata.admin.security.mask.builder.class: Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder
    app.path.user_images: /uploads/images/users
    app.path.logo_image: /images/
    app.path.cv_pdf: /uploads/files/cv
    app.path.doc_file: /uploads/files/doc
    app.path.video_file: /uploads/files/video
    default_anneeScolaire: no-annee
    locales: '%env(LOCALES)%'
    default_locale: '%env(DEFAULT_LOCALE)%'
    mercure_secret_key: '%env(MERCURE_JWT_SECRET)%'
    fr_only: '%env(bool:FR_ONLY)%'
    dev_by: '%env(DEV_BY)%'
    dev_by_site: '%env(DEV_BY_SITE)%'
    notif: '%env(bool:NOTIF)%'
    smsNotif: '%env(bool:SMS_NOTIF)%'
    mercureNotif: '%env(bool:MERCURE_NOTIF)%'
    firebaseNotif: '%env(bool:FIREBASE_NOTIF)%'
    smsApiKey: '%env(SMS_API_KEY)%'
    senderId: '%env(SENDER_ID)%'
    financeLink: '%env(bool:FINANCE)%'
    financeUrl: '%env(FINANCE_URL)%'
    templateBulletin: '%env(TEMPLATE_BULLETIN)%'
    prefix: '%env(PREFIX)%'
    env(TEMPLATE_BULLETIN): "default"
    schoolLink: '%env(SCHOOLLINK)%'
    schoolDomain: '%env(SCHOOL_DOMAIN)%'
    moduleConfigNotification: '%env(bool:MODULE_CONFIG_NOTIFICATION)%'
    moduleService: '%env(bool:MODULE_SERVICE)%'
    moduleCantine: '%env(bool:MODULE_CANTINE)%'
    env(MODULE_CONFIG_NOTIFICATION): true
    env(MODULE_SERVICE): true
    env(MODULE_CANTINE): true

twig:
    globals:
        toutAnneeScolaire: tout les années
        anneeScolaires: [2020-2021]
        fr_only: '%env(bool:FR_ONLY)%'
        notif: '%env(bool:NOTIF)%'
        financeLink: '%env(bool:FINANCE)%'
        financeUrl: '%env(FINANCE_URL)%'
        schoolLink: '%env(SCHOOLLINK)%'
        default_locale: '%default_locale%'
        dev_by_site: '%env(DEV_BY_SITE)%'
        dev_by: '%env(DEV_BY)%'
        moduleConfigNotification: '%moduleConfigNotification%'
        moduleService: '%moduleService%'
        moduleCantine: '%moduleCantine%'
        mercureNotif: '%mercureNotif%'

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: false
        bind:
            $smsNotif: '%smsNotif%'
            $mercureNotif: '%mercureNotif%'
            $firebaseNotif: '%firebaseNotif%'
            $notif: '%notif%'
            $financeLink: '%financeLink%'
            $financeUrl: '%financeUrl%'
            $templateBulletin: '%templateBulletin%'
            $smsApiKey: '%smsApiKey%'
            $senderId: '%senderId%'
            $prefix: '%prefix%'
            $moduleConfigNotification: '%moduleConfigNotification%'
            $moduleService: '%moduleService%'
            $moduleCantine: '%moduleCantine%'


    # 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/{Entity,Migrations,Tests,Application}'

    # 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']
    security.acl.permission.map:
        class: Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap

    App\EventSubscriber\AnneeScolaireSubscriber:
        arguments: ['@App\Repository\AnneeScolaireRepository','%default_anneeScolaire%']
    gedmo.listener.tree:
        class: Gedmo\Tree\TreeListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }
        calls:
            - [ setAnnotationReader, [ "@annotation_reader" ] ]

    Gedmo\Translatable\TranslatableListener:
        tags:
            - { name: doctrine.event_subscriber, connection: default }
        calls:
            - [ setAnnotationReader, [ "@annotation_reader" ] ]
            - [ setDefaultLocale, [ "%default_locale%" ] ]
            - [ setTranslationFallback, [ false ] ]

    gedmo.listener.timestampable:
        class: Gedmo\Timestampable\TimestampableListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }
        calls:
            - [ setAnnotationReader, [ "@annotation_reader" ] ]

    gedmo.listener.sluggable:
        class: Gedmo\Sluggable\SluggableListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }
        calls:
            - [ setAnnotationReader, [ "@annotation_reader" ] ]

    gedmo.listener.sortable:
        class: Gedmo\Sortable\SortableListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }
        calls:
            - [ setAnnotationReader, [ "@annotation_reader" ] ]

    gedmo.listener.softdeleteable:
        class: Gedmo\SoftDeleteable\SoftDeleteableListener
        tags:
            - { name: doctrine.event_listener, event: 'onFlush' }
            - { name: doctrine.event_listener, event: 'loadClassMetadata' }
        calls:
            - [ setAnnotationReader, [ "@annotation_reader" ] ]

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

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

#    admin.extension.workflow:
#        class: Yokai\SonataWorkflow\Admin\Extension\WorkflowExtension
#        public: true
#        arguments:
#            - '@workflow.registry'
    Yokai\SonataWorkflow\Controller\WorkflowController:
        autowire: true
        tags: ['controller.service_arguments']

    App\EventSubscriber\CalendarSubscriber:
    app.block.dashboard:
        class: App\Block\DashboardBlockService
        arguments:
            - "@doctrine.orm.entity_manager"
            - "@security.token_storage"
            - "@service_container"
            - "app.block.dashboard"
            - "@templating"
        tags:
            - { name: sonata.block }
    App\EventListener\DoctrineSubscriber:
        class: App\EventListener\DoctrineSubscriber
        arguments:
            - '@security.token_storage'
            - '@request_stack'
            - '@session'
        tags:
            - { name: 'doctrine.event_subscriber' }
    #app.block.logger:
     #   class: App\Block\LoggServices
      #  arguments:
       #     - "@security.token_storage"
       # tags:
        #    - { name: doctrine.event_subscriber,  lazy: true, priority: 1 }

    admin.logs:
        class: App\Admin\LogsAdmin
        arguments: [~, App\Entity\logs, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: Historique }
        public: true

#    App\Service\MercureCookieGenerator:
#        arguments:
#            $secret: '%env(MERCURE_JWT_KEY)%'
#    App\Mercure\JwtProvider:
#        arguments:
#            $secret: '%env(MERCURE_JWT_KEY)%'

    admin.configuration:
        class: App\Admin\ConfigurationAdmin
        arguments: [~, App\Entity\Configuration, App\Controller\ConfigurationAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: Configuration }
        public: true

    admin.langueMatiere:
        class: App\Admin\LangueMatiereAdmin
        arguments: [~, App\Entity\LangueMatiere, App\Controller\LangueMatiereAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: LangueMatiere }
        public: true

    app.menu_listener:
        class: App\EventListener\MenuBuilderListener
        tags:
            - { name: kernel.event_listener, event: sonata.admin.event.configure.menu.sidebar, method: addMenuItems }
        arguments: ["%financeLink%"]
    admin.driver:
        class: App\Admin\DriverAdmin
        arguments: [~, App\Entity\User, App\Controller\DriverAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: User }
        public: true

    admin.vehicule:
        class: App\Admin\VehiculeAdmin
        arguments: [~, App\Entity\Vehicule, App\Controller\VehiculeAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: Vehicule }
        public: true

    admin.circuit:
        class: App\Admin\CircuitAdmin
        arguments: [~, App\Entity\Circuit, App\Controller\CircuitAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: Circuit }
        public: true

    admin.voyage_attendance:
        class: App\Admin\VoyageAttendanceAdmin
        arguments: [~, App\Entity\VoyageAttendance, App\Controller\VoyageAttendanceAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: VoyageAttendance }
        public: true

    admin.voyage:
        class: App\Admin\VoyageAdmin
        arguments: [~, App\Entity\Voyage, App\Controller\VoyageAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: Voyage }
        public: true

    admin.list_demande_parent:
        class: App\Admin\ListDemandeParentAdmin
        arguments: [~, App\Entity\ListDemandeParent, App\Controller\ListDemandeParentAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: ListDemandeParent }
        public: true

    admin.conseil_text:
        class: App\Admin\ConseilTypeAdmin
        arguments: [~, App\Entity\ConseilType, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: ConseilType }
        public: true

#    app.translate.object.helper:
#        class: App\Service\TranslateObjectHelper
#        arguments:
#            $translator: '@translator'
#        public: true
#    App\Entity\ServicePaiement:
#        arguments:
#            $translateObjectHelper: '@app.translate.object.helper'
#        public: true

    admin.convention:
        class: App\Admin\ConventionAdmin
        arguments: [~, App\Entity\Convention, App\Controller\ConventionAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, group: admin, label: Convention }
        public: true


    'App\Doctrine\CurrentYearExtension':
        tags:
            - { name: api_platform.doctrine.orm.query_extension.collection }
            - { name: api_platform.doctrine.orm.query_extension.item }
