# 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:
    locale: 'en'
    encrypt_key: M5SWDGMo8b5SeupQCZYK8koURuCYlg14KE+EgODKeVs=
    router.request_context.scheme: 'https'
    asset.request_context.secure: true
    sonata.user.admin.user.controller: 'App\Controller\CRUD\CRUDController'
    sonata.media.admin.media.class: 'App\Admin\MediaAdmin'
    sonata.media.admin.gallery.class: 'App\Admin\GalleryAdmin'

    # PARAMETRES DES IMPORTS POSSIBLE POUR L'APPLICATION DE GESTION DE MONNAIE LOCALE COMPLEMENTAIRE
    app.import.separator: ';'
    app.import.header:
        groupe:
            header: 'idmlc;nom;description;compte'
            example: 'Groupe local n°1;<b>Groupe local n°1</b>;123'
            filecsv: '/csv/groupe.csv'
            filexls: '/csv/groupe.xlsx'
            filenum: '/csv/groupe.numbers'
            helper: ''
        comptoir:
            header: 'idmlc;groupe;nom;description;adresse;cpostal;ville;latitude;longitude;compte;contact1;phone1;email1;contact2;phone2;email2;contact3;phone3;email3'
            example: 'Groupe local n°1;Comptoir n°1;<b>Comptoir n°1</b>;2, rue charles de gaulle;12345;Paris;45,12345;3,12345;123;M. Jean Dupont;0612345678;jean.dupont@email.com;Contact comptoir;0198765432;contact.comptoir@email.com;Contact 3;0198765432;contact.comptoir2@email.com'
            filecsv: '/csv/comptoir.csv'
            filexls: '/csv/comptoir.xlsx'
            filenum: '/csv/comptoir.numbers'
            helper: ''
        adherent:
            header: 'idmlc;groupe;firstname;lastname;email;phone;mobile;adresse;cpostal;ville;ecompte;cotisations'
            example: 'Groupe local n°1;Jean;Dupont;jean.dupont@gmail.com;013456789;0612345678;"2; rue Charles de gaulle";12345;Paris;"12,34";"10:2017,10:2018,10:2019"'
            filecsv: '/csv/adherent.csv'
            filexls: '/csv/adherent.xlsx'
            filenum: '/csv/adherent.numbers'
            helper: ''
        prestataire:
            header: 'idmlc;groupe;adresse;cpostal;ville;raison;ecompte;metier;statut;responsable;iban;siret;web;horaires;description;rubriques;tags;tauxreconversion;contact1;phone1;email1;contact2;phone2;email2;contact3;phone3;email3'
            example: 'Groupe local n°1;2, rue Charles de gaulle;12345;Paris;Nom du prestataire;123,45;Directeur;SARL;Jean Dupont;FR7630001007941234567890185;732 829 320 00074;www.siteweb.com;Dimanche de 8h à 12h;<b>Description du prestataire</b>;Amap,Fruits,Légumes,Marchés;tag1,tag2;2;M. Jean Dupont;0123456789;jean.dupont@email.com;Contact comptoir;0698765432;contact.comptoir@email.com;Contact 3;0198765432;contact.comptoir2@email.com'
            filecsv: '/csv/prestataire.csv'
            filexls: '/csv/prestataire.xlsx'
            filenum: '/csv/prestataire.numbers'
            helper: ''
        flux:
            header: 'exp_idmlc|exp;exp_type;dest_idmlc|dest;dest_type;user_email;montant;devise;date;type;moyen;reference;tauxreconversion;data'
            example: '12987542;prestataire;prestamonnaielocale;prestataire;toto@toto.com;10;euro;2020-11-29 14:53;cotisation;cb;1007941234567890185;0;toto,titi,tutu...'
            filecsv: '/csv/flux.csv'
            filexls: '/csv/flux.xlsx'
            filenum: '/csv/flux.numbers'
            helper: "Import des flux passés qui seront uniquement de l'historique et sans impact sur les balances de compte"
        ssa:
            header: 'email;cotisation_amount;foyer;caisse_ssa'
            example: 'jean.dupont@gmail.com;100;2;Nom de la caisse SSA si plusieurs'
            filecsv: '/csv/ssa.csv'
            filexls: '/csv/ssa.xlsx'
            filenum: '/csv/ssa.numbers'
            helper: 'Import des cotisations minimums/recommandées et du nombre de personne dans le foyer pour des adhérents existants'
        adherent_ssa:
            header: 'idmlc;groupe;email;prenom;nom;phone;mobile;adresse;cpostal;ville;cotisations;cotisation_min;foyer;caisse_ssa'
            example: 'Groupe local n°1;jean.dupont@gmail.com;Jean;Dupont;013456789;0612345678;"2; rue Charles de gaulle";12345;Paris;"10:2017,10:2018,10:2019";100;2;Nom de la caisse SSA si plusieurs'
            filecsv: '/csv/adherent_ssa.csv'
            filexls: '/csv/adherent_ssa.xlsx'
            filenum: '/csv/adherent_ssa.numbers'
            helper: "Import des adhérents avec ajout d'une participation à la caisse SSA avec cotisations minimums/recommandées et du nombre de personne dans le foyer"

# SERVICES
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.

    # 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,Factory,Doctrine,Listener,Entity,Migrations,Tests,Twig,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

    # Définition du prefix pour les tables
    #   -> Préfixes abandonnés pour l'instant
    # App\Doctrine\TablePrefix:
    #     arguments:
    #         $prefix: '%env(string:DATABASE_PREFIX)%'
    #     tags:
    #         - { name: doctrine.event_subscriber, connection: default }

    # cache doctrine for bazinga geocoder
    mlc_cache_adapter:
        class: Doctrine\Common\Cache\ApcCache

    # add more service definitions when explicit configuration is needed
    # please note that last definitions always *replace* previous ones
    apikey_authenticator:
        class:  App\Security\ApiKeyAuthenticator
        public: false

    api_key_user_provider:
        class: App\Security\ApiKeyUserProvider
        arguments:
            - '@doctrine.orm.entity_manager'

    redirect.after.login:
        class: App\Listener\AfterLoginRedirection
        autowire: false
        arguments: ['@router', '@doctrine.orm.entity_manager', '@security.token_storage', '@session', '@household_size_display_service']

    household_size_display_service:
        class: App\Service\HouseholdSizeDisplayService

    App\Service\BofficeApiClient:
        arguments:
            $bofficeApiUrl: '%boffice_api_url%'
            $cache: '@cache.app'

    App\Controller\InstallationController:
        arguments:
            $emailErrorTo: '%env(string:EMAIL_ERROR)%'
            $emailErrorFrom: '%env(string:EMAIL_ERROR_FROM)%'
        tags: ['controller.service_arguments']

    app.utils.custom_entity_manager:
        class: App\Utils\CustomEntityManager

    # Email listener for handling email events
    App\EventListener\EmailListener:
        arguments:
            $fromEmail: '%env(string:EMAIL_ERROR_FROM)%'
        tags:
            - { name: kernel.event_subscriber }

    # Service de notifications email SEPA/SSA
    App\Service\Sepa\SepaNotificationService:
        arguments:
            $mailer: '@swiftmailer.mailer.default'
            $templating: '@twig'
            $translator: '@translator'
            $logger: '@logger'
            $fromEmail: '%env(string:EMAIL_USER_FROM)%'

    app.utils.operations:
        class: App\Utils\OperationUtils
        autowire: false
        arguments: ['@app.utils.custom_entity_manager', '@session', '@security.helper', '@event_dispatcher']

    app.utils.cotisations:
        class: App\Utils\CotisationUtils
        autowire: false
        public: true
        arguments: ['@app.utils.custom_entity_manager', '@session', '@security.helper', '@event_dispatcher']

    app.utils.account:
        class: App\Utils\AccountUtils
        autowire: false
        arguments: ['@doctrine.orm.entity_manager']

    app.twig.main.extension:
        class: App\Twig\AppExtension
        autowire: false
        arguments: ["@service_container", "@security.helper", "@doctrine.orm.entity_manager", "@knp_paginator", "@session", "@app.utils.operations", "@app.utils.cotisations"]

    app.twig.logentry.extension:
        class: App\Twig\LogEntryExtension
        autowire: false
        arguments: ["@doctrine.orm.entity_manager"]

    app.twig.unserialize.extension:
        class: App\Twig\UnserializeExtension
        autowire: false

    app.twig.getclass.extension:
        class: App\Twig\GetClassExtension
        autowire: false

    app.twig.extension.flux:
        class: App\Twig\FluxExtension
        autowire: false
        arguments: ["@service_container", "@security.helper", "@doctrine.orm.entity_manager", "@knp_paginator", "@session"]

    app.twig.mlc.globals.extension:
        class: App\Twig\MlcGlobalsExtension
        autowire: false
        arguments: ["@doctrine.orm.entity_manager"]

    app.twig.ssa.extension:
        class: App\Twig\SsaExtension
        autowire: true

    app.listener.unitofwork:
        class: App\Listener\UnitOfWorkListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }

    app.twig.form.extension:
        class: App\Twig\FormExtension
        autowire: false
        arguments: ["@app.formfactory"]

    app.twig.stats.extension:
        class: App\Twig\StatsExtension
        autowire: true

    app.twig.sepa.extension:
        class: App\Twig\SepaExtension
        autowire: true

    # Listener pour activer automatiquement le filtre SoftDeleteable
    App\EventListener\SoftDeleteableFilterListener:
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@stof_doctrine_extensions.listener.softdeleteable'
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 100 }

    App\Monolog\CronLogMailActivationStrategy:
        arguments:
            $environment: '%kernel.environment%'

    app.formfactory:
        class: App\Factory\FormFactory
        autowire: true
        public: true

    app.flux.listener:
        class: App\Listener\FluxListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }

    app.hidden_entity_type_extension:
        class: App\Form\HiddenEntityExtension
        tags:
            - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\HiddenType }

    app.listener.geoloc.preupdate:
        class: App\EventListener\GeolocListener
        tags:
            - { name: doctrine.event_listener, event: preUpdate }
    app.listener.geoloc.postPersist:
        class: App\EventListener\GeolocListener
        tags:
            - { name: doctrine.event_listener, event: postPersist }

    mlc.user.listener:
        class: App\EventListener\UserListener
        autowire: true
        tags:
            - { name: kernel.event_subscriber }

    app.form.extension.media:
        class: App\Form\Extension\MediaTypeExtension
        tags:
            - { name: form.type_extension }
            # - { name: form.type_extension, extended_type: Sonata\MediaBundle\Form\Type\MediaType }

    app.security.handler.role:
        class: App\Security\Handler\VoterSecurityHandler
        arguments:
            - '@security.authorization_checker'
            - [ROLE_SUPER_ADMIN]
        calls:
            - [setManager, ['@doctrine.orm.entity_manager']]

    app.payzen_gateway_factory:
        class: Payum\Core\Bridge\Symfony\Builder\GatewayFactoryBuilder
        arguments: [Ekyna\Component\Payum\Payzen\PayzenGatewayFactory]
        tags:
            - { name: payum.gateway_factory_builder, factory: payzen }

    ###### Configuration de l'admin ######

    admin.block.dashboard:
        class: App\Block\DashboardKohinosBlock
        arguments:
            - '@twig'
        tags:
            - { name: sonata.block }

    admin.block.charts:
        class: App\Block\ChartsBlock
        arguments:
            - '@twig'
        tags:
            - { name: sonata.block }

    admin.adherent.gerer:
        class: App\Admin\AdherentAdmin
        # arguments: [~, App\Entity\Adherent, 'PixSortableBehaviorBundle:SortableAdmin']
        arguments: [~, App\Entity\Adherent, 'App\Controller\CRUD\CRUDController']
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Adherent"
              label: "Liste"
            # - group: "Contenu"
            # - label: "Adhérents"
            # - label_catalogue: "App"
        public: true
        calls:
            - [ setUserManager, ['@fos_user.user_manager']]
            - [ setSecurity, ['@security.helper']]
            - [ setEventDispatcher, ['@event_dispatcher']]
            - [ setHouseholdSizeDisplayService, ['@household_size_display_service']]

    admin.all.cotisations:
        class: App\Admin\CotisationAdmin
        arguments: [~, App\Entity\Cotisation, 'App\Controller\CRUD\CRUDController']
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Flux"
              label: "Cotisations"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]
            - [ setOperationUtils, ['@app.utils.operations']]
            - [ setCivilYearService, ['@App\Service\CivilYearService']]

    admin.all.achatsmonnaie:
        class: App\Admin\AchatMonnaieAdmin
        arguments: [~, App\Entity\AchatMonnaie, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Flux"
              label: "Achats de monnaie"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.all.demande.achatsmonnaie:
        class: App\Admin\AchatMonnaieAConfirmerAdmin
        arguments: [~, App\Entity\AchatMonnaieAConfirmer, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Flux"
              label: "Demandes d'achat de monnaie"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.adherent.cotisations:
        class: App\Admin\CotisationAdherentAdmin
        arguments: [~, App\Entity\CotisationAdherent, 'App\Controller\CRUD\CRUDController']
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Adherent"
              label: "Cotisation"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]
            - [ setOperationUtils, ['@app.utils.operations']]
            - [ setCivilYearService, ['@App\Service\CivilYearService']]

    admin.prestataire.gerer:
        class: App\Admin\PrestataireAdmin
        arguments: [~, App\Entity\Prestataire, App\Controller\PrestataireAdminController]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Prestataire"
              label: "Liste"
        public: true
        calls:
            - [ setUserManager, ['@fos_user.user_manager']]
            - [ addChild, ['@sonata.user.admin.user', 'user']]
            - [ setSecurity, ['@security.helper']]
            - [ setPool, ['@sonata.media.pool']]
            - [ setEventDispatcher, ['@event_dispatcher']]

    admin.prestataire.cotisations:
        class: App\Admin\CotisationPrestataireAdmin
        arguments: [~, App\Entity\CotisationPrestataire, 'App\Controller\CRUD\CRUDController']
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Prestataire"
              label: "Cotisation"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]
            - [ setOperationUtils, ['@app.utils.operations']]
            - [ setCivilYearService, ['@App\Service\CivilYearService']]

    admin.groupe.gerer:
        class: App\Admin\GroupeAdmin
        arguments: [~, App\Entity\Groupe, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              label: "Groupes locaux"
        public: true

    admin.comptoir.gerer:
        class: App\Admin\ComptoirAdmin
        arguments: [~, App\Entity\Comptoir, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              label: "Comptoirs"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.groupepresta.gerer:
        class: App\Admin\GroupeprestataireAdmin
        arguments: [~, App\Entity\Groupeprestataire, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Prestataire"
              label: "AMAP / Marchés"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.etatpresta.gerer:
        class: App\Admin\EtatprestataireAdmin
        arguments: [~, App\Entity\EtatPrestataire, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Prestataire"
              label: "Tags"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.news.gerer:
        class: App\Admin\NewsAdmin
        arguments: [~, App\Entity\News, 'PixSortableBehaviorBundle:SortableAdmin']
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Contenu"
              label: "Actualités"
        public: true

    admin.globalparameter.gerer:
        class: App\Admin\GlobalParameterAdmin
        arguments: [~, App\Entity\GlobalParameter, App\Controller\Admin\GlobalParameterAdminController]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Contenu"
              label: "Configuration"
        public: true

    admin.document.gerer:
        class: App\Admin\DocumentAdmin
        arguments: [~, App\Entity\Document, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Contenu"
              label: "Documents"
        public: true

    admin.rubrique.gerer:
        class: App\Admin\RubriqueAdmin
        arguments: [~, App\Entity\Rubrique, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Contenu"
              label: "Rubriques"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.faq.gerer:
        class: App\Admin\FaqAdmin
        arguments: [~, App\Entity\Faq, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Contenu"
              label: "FAQs"
        public: true

    admin.traduction.gerer:
        class: App\Admin\TraductionAdmin
        arguments: [~, Lexik\Bundle\TranslationBundle\Entity\Translation, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Traduction"
              label: "Traductions"
        public: true

    admin.flux.gerer:
        class: App\Admin\FluxAdmin
        arguments: [~, App\Entity\Flux, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Flux"
              label: "Flux"
              pager_type: "simple"
        public: true
        calls:
            - [ setSubClasses, [{transaction: 'App\Entity\Transaction', transfert: 'App\Entity\Transfert', cotisation: 'App\Entity\Cotisation', achat_monnaie: 'App\Entity\AchatMonnaie'}]]
            - [ setTranslator, ['@translator']]
            - [ setSecurity, ['@security.helper']]

    admin.flux.ssa:
        class: App\Admin\FluxSsaAdmin
        arguments: [~, App\Entity\Flux, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Flux"
              label: "Flux SSA"
              pager_type: "simple"
        public: true
        calls:
            - [ setTranslator, ['@translator']]
            - [ setSecurity, ['@security.helper']]

    admin.flux.euros:
        class: App\Admin\FluxEurosAdmin
        arguments: [~, App\Entity\Flux, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Flux"
              label: "Flux Euros"
              pager_type: "simple"
        public: true
        calls:
            - [ setTranslator, ['@translator']]
            - [ setSecurity, ['@security.helper']]

    admin.operation.gerer:
        class: App\Admin\OperationAdmin
        arguments: [~, App\Entity\Operation, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Operation"
              label: "Operation"
              pager_type: "simple"
        public: true
        calls:
            - [ setSubClasses, [{adherent: 'App\Entity\OperationAdherent', prestataire: 'App\Entity\OperationPrestataire', comptoir: 'App\Entity\OperationComptoir', groupe: 'App\Entity\OperationGroupe', siege: 'App\Entity\OperationSiege'}]]
            - [ setSecurity, ['@security.helper']]

    admin.operation.prestataire.gerer:
        class: App\Admin\OperationPrestataireAdmin
        arguments: [~, App\Entity\OperationPrestataire, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Operations"
              label: "Prestataires"
              pager_type: "simple"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.operation.adherent.gerer:
        class: App\Admin\OperationAdherentAdmin
        arguments: [~, App\Entity\OperationAdherent, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Operations"
              label: "Adherents"
              pager_type: "simple"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.operation.groupe.gerer:
        class: App\Admin\OperationGroupeAdmin
        arguments: [~, App\Entity\OperationGroupe, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Operations"
              label: "Groupes"
              pager_type: "simple"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.operation.comptoir.gerer:
        class: App\Admin\OperationComptoirAdmin
        arguments: [~, App\Entity\OperationComptoir, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Operations"
              label: "Comptoirs"
              pager_type: "simple"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.operation.siege.gerer:
        class: App\Admin\OperationSiegeAdmin
        arguments: [~, App\Entity\OperationSiege, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Operations"
              label: "Siege"
              pager_type: "simple"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.transfert.gerer:
        class: App\Admin\TransfertAdmin
        arguments: [~, App\Entity\Transfert, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Flux"
              label: "Transferts"
              pager_type: "simple"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]
            - [ setSession, ['@session']]

    admin.transaction.gerer:
        class: App\Admin\TransactionAdmin
        arguments: [~, App\Entity\Transaction, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Flux"
              label: "Transactions"
              pager_type: "simple"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.reconversion.gerer:
        class: App\Admin\ReconversionAdmin
        arguments: [~, App\Entity\Reconversion, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Flux"
              label: "Reconversions"
              pager_type: "simple"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.page.gerer:
        class: App\Admin\PageAdmin
        arguments: [~, App\Entity\Page, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Pages"
              label: "Pages"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.import:
        class: App\Admin\ImportAdmin
        arguments: [~, App\Entity\Import, App\Controller\ImportController]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Import"
              label: "Import"
              show_mosaic_button: false
        public: true

    admin.solidoume:
        class: App\Admin\SolidoumeAdmin
        arguments: [~, App\Entity\SolidoumeItem, App\Controller\SSAAdminController]
        calls:
            - [setOperationUtils, ['@App\Utils\OperationUtils']]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Sécurité Sociale Alimentaire"
              label: "Sécurité Sociale Alimentaire"
              show_mosaic_button: false
        public: true

    admin.solidoume.parameters:
        class: App\Admin\SolidoumeParamAdmin
        arguments: [~, App\Entity\SolidoumeParameter, App\Controller\SolidoumeParameterController]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Paramètres Sécurité Sociale Alimentaire"
              label: "Paramètres Sécurité Sociale Alimentaire"

    # SEPA Direct Debit Admin Services
    admin.sepa.mandate:
        class: App\Admin\SepaMandateAdmin
        arguments: [~, App\Entity\SepaMandate, 'App\Controller\Admin\SepaMandateAdminController']
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "SEPA"
              label: "Mandats SEPA"
        public: true

    admin.sepa.mlc_subscription:
        class: App\Admin\RecurringMlcSubscriptionRequestAdmin
        arguments: [~, App\Entity\RecurringMlcSubscriptionRequest, 'App\Controller\Admin\RecurringMlcSubscriptionRequestAdminController']
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "SEPA"
              label: "Cotisations MLC (annuelles)"
        public: true

    admin.sepa.ssa_subscription:
        class: App\Admin\RecurringSsaSubscriptionRequestAdmin
        arguments: [~, App\Entity\RecurringSsaSubscriptionRequest, 'App\Controller\Admin\RecurringSsaSubscriptionRequestAdminController']
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "SEPA"
              label: "Cotisations SSA (mensuelles)"
        public: true

    admin.sepa.purchase:
        class: App\Admin\RecurringPurchaseRequestAdmin
        arguments: [~, App\Entity\RecurringPurchaseRequest, 'App\Controller\Admin\RecurringPurchaseRequestAdminController']
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "SEPA"
              label: "Achats mensuels récurrents"
        public: true

    admin.dons:
        class: App\Admin\DonAdmin
        arguments: [~, App\Entity\Don, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Flux"
              label: "Dons"
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    admin.helloasso:
        class: App\Admin\HelloAssoAdmin
        arguments: [~, App\Entity\HelloAsso, App\Controller\HelloAssoController]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "HelloAsso"
              label: "HelloAsso"
              show_mosaic_button: false
        public: true
        calls:
            - [ setSecurity, ['@security.helper']]

    # Email Management Admin Services
    admin.email.log:
        class: App\Admin\EmailLogAdmin
        arguments: [~, App\Entity\EmailLog, App\Controller\Admin\EmailLogAdminController]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "Email"
              label: "Historique des emails"
        public: true

    App\Controller\Admin\EmailLogAdminController:
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@cache.app'
            - '@App\Twig\EmailTypeExtension'
        tags: ['controller.service_arguments']

    # Email Template Controller (standalone - EmailTemplate is not a Doctrine entity)
    App\Controller\Admin\EmailTemplateController:
        arguments:
            - '@App\Service\Email\EmailTemplateService'
            - '@App\Service\Email\EmailVariableRegistryService'
            - '@twig'
        tags: ['controller.service_arguments']

    # Email Services
    App\Service\Email\EmailLogService:
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@App\Repository\UserRepository'
            - '@logger'
        public: true

    App\Service\Email\EmailTemplateService:
        arguments:
            - '%kernel.project_dir%'
            - '@logger'
        public: true

    App\Service\Email\EmailVariableRegistryService:
        public: true

    # Email Type Formatting Extension (centralizes type display logic)
    App\Twig\EmailTypeExtension:
        tags: ['twig.extension']
        public: true

    # Email Mailer Abstraction (for future Symfony Mailer migration)
    # Note: SwiftMailerAdapter is available but not required - existing code can continue using Swift_Mailer directly
    # When ready to migrate, inject MailerInterface instead of Swift_Mailer
    App\Service\Email\SwiftMailerAdapter:
        arguments:
            - '@swiftmailer.mailer.default'
            - 'noreply@kohinos.net'
        public: true

    App\Service\Email\MailerInterface:
        alias: App\Service\Email\SwiftMailerAdapter

    # Email Logging Listener (intercepts all sent emails)
    App\EventListener\EmailLoggingListener:
        arguments:
            - '@App\Service\Email\EmailLogService'
            - '@logger'
        tags:
            - { name: swiftmailer.default.plugin }

    sonata.media.provider.csv:
        class: App\Admin\ImportProvider
        tags:
            - { name: sonata.media.provider }
        arguments:
            - 'sonata.media.provider.csv'
            - '@sonata.media.filesystem.local'
            - '@sonata.media.cdn.server'
            - '@sonata.media.generator.default'
            - '@sonata.media.thumbnail.format'
            - ['csv', 'txt']
            - ['text/csv', 'application/vnd.ms-excel', 'text/plain', 'text/x-csv', 'application/csv', 'text/comma-separated-values', 'text/x-comma-separated-values', 'text/tab-separated-values']
    # admin.flux.gerer:
    #     class: App\Admin\FluxAdmin
    #     arguments: [~, App\Entity\Transaction, ~]
    #     tags:
    #         - name: sonata.admin
    #           manager_type: orm
    #           group: "Comptabilité"
    #           label: "Flux"
    #     public: true

    app.flash_messenger:
        class: App\Listener\Flash
        arguments: ["@session"]
        tags:
            - { name: kernel.event_listener, event: kernel.response }

    App\Swagger\SwaggerDecorator:
        decorates: 'api_platform.swagger.normalizer.api_gateway'
        arguments: [ '@App\Swagger\SwaggerDecorator.inner' ]
        autoconfigure: false

    filter.configurator:
        class: App\Filter\Configurator
        arguments: ["@doctrine.orm.entity_manager"]
        tags:
            - { name: kernel.event_listener, event: kernel.controller }

    App\Serializer\ApiNormalizer:
        decorates: 'api_platform.serializer.normalizer.item'
        arguments: [ '@App\Serializer\ApiNormalizer.inner' ]

    # @TODO : A FINIR : si un adhérent ou un prestataire n'a pas sa cotisation à jour => redirection vers une page pour pouvoir :
    #   - cotiser
    #   - voir son ecompte
    #
    # app.kernel.event.listener:
    #     class: App\EventListener\RequestListener
    #     arguments: ['@doctrine.orm.entity_manager', '@security.token_storage', '@router']
    #     tags:
    #         - { name: 'kernel.event_listener', event: 'kernel.request', method: 'onKernelRequest' }

    ambta_doctrine_encrypt.orm_subscriber:
        class: Ambta\DoctrineEncryptBundle\Subscribers\DoctrineEncryptSubscriber
        arguments: ["@annotation_reader", "%ambta_doctrine_encrypt.encryptor_class_name%"]
        tags:
            -  { name: doctrine.event_subscriber }
    ambta_doctrine_encrypt.subscriber:
        public: true
        alias: ambta_doctrine_encrypt.orm_subscriber
    ambta_doctrine_encrypt.encryptor:
        class: Ambta\DoctrineEncryptBundle\Services\Encryptor

    Ambta\DoctrineEncryptBundle\Command\DoctrineEncryptStatusCommand:
        public: false
        tags:
            - { name: console.command, command: 'doctrine:encrypt:status' }

    Doctrine\Migrations\Version\DbalMigrationFactory: ~
    App\Utils\MigrationFactoryDecorator:
        decorates: Doctrine\Migrations\Version\DbalMigrationFactory
        arguments: ['@App\Utils\MigrationFactoryDecorator.inner', '@service_container']

    # To fix this error :
    # In ModelManager.php line 627:
    # Cannot initialize abstract class: App\Entity\AchatMonnaieAConfirmer
    App\Command\TranslationUpdateCommand:
      arguments:
        - '@translation.writer'
        - '@translation.reader'
        - '@translation.extractor'
        - '%kernel.default_locale%'
        - '%translator.default_path%'
        - ''
        - []
        - []
      decorates: console.command.translation_update
      class: App\Command\TranslationUpdateCommand

    App\Command\TestEmailCommand:
      arguments:
        - '@swiftmailer.mailer.default'
        - '%env(EMAIL_USER_FROM)%'
        - '%env(EMAIL_ERROR_FROM)%'
      tags:
        - { name: 'console.command' }

    # ========================================
    # NEW MENU BUNDLE - Modern Symfony 6.4 Compatible
    # Replaces prodigious/sonata-menu-bundle
    # ========================================

    # Menu Repositories (autowired)
    App\MenuBundle\Repository\MenuRepository: ~
    App\MenuBundle\Repository\MenuItemRepository: ~

    # Menu Manager
    App\MenuBundle\Manager\MenuManager:
        arguments:
            $em: '@doctrine.orm.entity_manager'
            $menuRepository: '@App\MenuBundle\Repository\MenuRepository'
            $menuItemRepository: '@App\MenuBundle\Repository\MenuItemRepository'
        public: true

    # Backward compatibility alias (keep old service name working)
    prodigious_sonata_menu.manager:
        alias: App\MenuBundle\Manager\MenuManager
        public: true

    # Twig Extension
    App\MenuBundle\Twig\MenuExtension:
        arguments:
            $menuManager: '@App\MenuBundle\Manager\MenuManager'
        tags:
            - { name: twig.extension }

    # Keep old extension working for backward compatibility
    app.twig.menu.extension:
        alias: App\MenuBundle\Twig\MenuExtension

    # Sonata Admin Services
    App\MenuBundle\Admin\MenuAdmin:
        arguments: [~, App\MenuBundle\Entity\Menu, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Menus', group: 'menu_builder', icon: '<i class="fa fa-list"></i>' }
        public: true

    # Alias for backward compatibility
    prodigious_sonata_menu.admin.menu:
        alias: App\MenuBundle\Admin\MenuAdmin
        public: true

    App\MenuBundle\Admin\MenuItemAdmin:
        arguments: [~, App\MenuBundle\Entity\MenuItem, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Éléments de menu', group: 'menu_builder', icon: '<i class="fa fa-link"></i>' }
        public: true

    # Alias for backward compatibility
    prodigious_sonata_menu.admin.menu_item:
        alias: App\MenuBundle\Admin\MenuItemAdmin
        public: true

    app.menu_listener:
        class: App\EventListener\MenuBuilderListener
        tags:
            - { name: kernel.event_listener, event: sonata.admin.event.configure.menu.sidebar, method: addMenuItems }

    # HelloAsso API Controller - Injection des variables d'environnement (optionnelles)
    App\Controller\HelloAssoApiController:
        arguments:
            $helloassoApiUrl: '%env(default::HELLOASSO_API_URL)%'
            $helloassoClientId: '%env(default::HELLOASSO_CLIENT_ID)%'
            $helloassoClientSecret: '%env(default::HELLOASSO_CLIENT_SECRET)%'
            $helloassoUrlCotisationAdherent: '%env(default::HELLOASSO_URL_COTISATION_ADHERENT)%'
            $helloassoUrlCotisationPrestataire: '%env(default::HELLOASSO_URL_COTISATION_PRESTATAIRE)%'
            $helloassoUrlEmlcAdherent: '%env(default::HELLOASSO_URL_EMLC_ADHERENT)%'
            $helloassoUrlEmlcPrestataire: '%env(default::HELLOASSO_URL_EMLC_PRESTATAIRE)%'

    # GDPR Audit Log Admin Services
    admin.audit.log:
        class: App\Admin\AuditLogAdmin
        arguments: [~, App\Entity\AuditLog, ~]
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "RGPD"
              label: "Journal d'audit"
        public: true

    # GDPR Audit Service
    App\Service\Audit\AuditService:
        arguments:
            $em: '@doctrine.orm.entity_manager'
            $requestStack: '@request_stack'
            $security: '@security.helper'
            $logger: '@logger'
            $auditLogRepository: '@App\Repository\AuditLogRepository'
        public: true

    # Audit Event Subscriber
    App\EventListener\AuditSubscriber:
        arguments:
            $auditService: '@App\Service\Audit\AuditService'
            $logger: '@logger'
        tags:
            - { name: kernel.event_subscriber }

    # GDPR Services
    App\Service\Gdpr\AnonymizationService:
        arguments:
            $em: '@doctrine.orm.entity_manager'
            $auditService: '@App\Service\Audit\AuditService'
            $logger: '@logger'
            $emailPrefix: 'anonymized'
            $emailDomain: 'deleted.local'
            $nameReplacement: 'ANONYMISÉ'
            $pseudonymSalt: '%env(default::GDPR_PSEUDONYM_SALT)%'

    App\Service\Gdpr\GdprExportService:
        arguments:
            $em: '@doctrine.orm.entity_manager'

    # GDPR Consent Service
    App\Service\Gdpr\ConsentService:
        arguments:
            $em: '@doctrine.orm.entity_manager'
            $consentRepository: '@App\Repository\UserConsentRepository'
            $globalParameterRepository: '@App\Repository\GlobalParameterRepository'
            $auditService: '@App\Service\Audit\AuditService'
            $logger: '@logger'

    # GDPR Controller (authenticated)
    App\Controller\GdprController:
        arguments:
            $em: '@doctrine.orm.entity_manager'
            $gdprExportService: '@App\Service\Gdpr\GdprExportService'
            $auditService: '@App\Service\Audit\AuditService'
            $gdprRequestRepository: '@App\Repository\GdprRequestRepository'
            $consentService: '@App\Service\Gdpr\ConsentService'
            $globalParameterRepository: '@App\Repository\GlobalParameterRepository'
            $householdSizeDisplayService: '@App\Service\HouseholdSizeDisplayService'
            $mailer: '@swiftmailer.mailer.default'
            $twig: '@twig'
            $logger: '@logger'
        tags: ['controller.service_arguments']

    # GDPR Public Controller (anonymous access - privacy policy)
    App\Controller\GdprPublicController:
        arguments:
            $globalParameterRepository: '@App\Repository\GlobalParameterRepository'
        tags: ['controller.service_arguments']

    # Security Voters
    App\Security\Voter\ExportVoter:
        arguments:
            $security: '@security.helper'
        tags:
            - { name: security.voter }

    App\Security\Voter\SsaVoter:
        arguments:
            $security: '@security.helper'
        tags:
            - { name: security.voter }

    # Export Profiles
    App\Service\Export\StandardExportProfile: ~
    App\Service\Export\PseudonymizedExportProfile: ~
    App\Service\Export\RawExportProfile: ~

    # GDPR Consent Check Listener (sets session flag for consent modal)
    App\EventListener\ConsentCheckListener:
        arguments:
            $security: '@security.helper'
            $consentService: '@App\Service\Gdpr\ConsentService'
            $householdSizeDisplayService: '@App\Service\HouseholdSizeDisplayService'
        tags:
            - { name: kernel.event_subscriber }

    # Switch User Listener (audit impersonation)
    App\EventListener\SwitchUserListener:
        arguments:
            $auditService: '@App\Service\Audit\AuditService'
            $logger: '@logger'
        tags:
            - { name: kernel.event_subscriber }

    # Sonata Export Listener (audit all admin exports)
    App\EventListener\SonataExportListener:
        arguments:
            $auditService: '@App\Service\Audit\AuditService'
            $security: '@security.helper'
            $logger: '@logger'
        tags:
            - { name: kernel.event_subscriber }

    # GDPR Request Admin
    admin.gdpr.request:
        class: App\Admin\GdprRequestAdmin
        arguments: [~, App\Entity\GdprRequest, 'App\Controller\Admin\GdprRequestAdminController']
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "RGPD"
              label: "Demandes RGPD"
        public: true

    # GDPR Consent Admin (SUPER_ADMIN only)
    admin.gdpr.consent:
        class: App\Admin\ConsentAdmin
        arguments:
            - ~
            - App\Entity\UserConsent
            - 'App\Controller\Admin\ConsentAdminController'
            - '@App\Repository\UserConsentRepository'
            - '@App\Repository\UserRepository'
            - '@App\Service\Gdpr\ConsentService'
        tags:
            - name: sonata.admin
              manager_type: orm
              group: "RGPD"
              label: "Consentements"
        public: true

    # UserConsent Repository
    App\Repository\UserConsentRepository:
        arguments:
            $registry: '@doctrine'
        tags:
            - { name: doctrine.repository_service }

    # GDPR Purge Command
    App\Command\GdprPurgeCommand:
        arguments:
            $em: '@doctrine.orm.entity_manager'
            $anonymizationService: '@App\Service\Gdpr\AnonymizationService'
            $auditService: '@App\Service\Audit\AuditService'
            $logger: '@logger'
        tags:
            - { name: console.command }

    # SEO Twig Extension
    App\Twig\SeoExtension:
        tags:
            - { name: twig.extension }

    # Branding Upload Service
    App\Service\BrandingUploadService:
        arguments:
            $projectDir: '%kernel.project_dir%'

    # Favicon Generator Service
    App\Service\FaviconGeneratorService:
        arguments:
            $projectDir: '%kernel.project_dir%'

    # File Exists Twig Extension
    App\Twig\FileExistsExtension:
        arguments:
            $projectDir: '%kernel.project_dir%'
        tags:
            - { name: twig.extension }
