# Symfony 6.4 services — DirectPotager
parameters:
    locale: '%env(LOCALE)%'
    web_path: '%kernel.project_dir%/public/'
    email_sender: '%env(EMAIL_SENDER)%'
    recaptcha_private_key: '%env(RECAPTCHA_PRIVATE_KEY)%'
    site_domain: '%env(SITE_DOMAIN)%'
    blog_url: '%env(BLOG_URL)%'

services:
    # Default configuration for services in *this* file
    _defaults:
        autowire: true
        autoconfigure: true
        public: false
        bind:
            $locale: '%env(LOCALE)%'
            $emailSender: '%env(EMAIL_SENDER)%'
            Sonata\UserBundle\Model\UserManagerInterface: '@sonata.user.manager.user'

    # 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/'
            - '../src/Entity/'
            - '../src/Kernel.php'
            - '../src/Application/'
            - '../src/PotagerBundle/'

    # ──────────────────────────────────────────────────────────────
    # Legacy PotagerBundle auto-registration (kept during migration)
    # ──────────────────────────────────────────────────────────────
    PotagerBundle\:
        resource: '../src/PotagerBundle/'
        exclude:
            - '../src/PotagerBundle/Entity/'

    # ──────────────────────────────────────────────────────────────
    # Twig Extension (migrated from AppBundle\Twig\TwigExtension)
    # ──────────────────────────────────────────────────────────────
    App\Twig\AppTwigExtension:
        arguments:
            $em: '@doctrine.orm.entity_manager'
        tags:
            - { name: twig.extension }
        public: false

    # ──────────────────────────────────────────────────────────────
    # Activity & Login listeners
    # ──────────────────────────────────────────────────────────────
    PotagerBundle\EventListener\ActivityListener:
        arguments:
            $tokenStorage: '@security.token_storage'
            $userManager: '@sonata.user.manager.user'
        tags:
            - { name: kernel.event_listener, event: kernel.controller, method: onCoreController }

    PotagerBundle\EventListener\LoginListener:
        arguments:
            $userManager: '@sonata.user.manager.user'
        tags:
            - { name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin }

    # ──────────────────────────────────────────────────────────────
    # GlobalHelper (was using @templating + @mailer — both removed)
    # ──────────────────────────────────────────────────────────────
    PotagerBundle\Helper\GlobalHelper:
        arguments:
            $twig: '@twig'
            $entityManager: '@doctrine.orm.entity_manager'
            $request_stack: '@request_stack'
            $translator: '@translator'
            $router: '@router'
            $tokenStorage: '@security.token_storage'
            $authChecker: '@security.authorization_checker'
            $brevoApiKey: '%env(BREVO_API_KEY)%'
        public: true

    # ──────────────────────────────────────────────────────────────
    # OAuth user provider
    # ──────────────────────────────────────────────────────────────
    App\Security\OAuthUserProvider:
        arguments:
            $registry: '@doctrine'
            $requestStack: '@request_stack'
        tags:
            - { name: hwi_oauth.user_provider }

    # Alias for backward-compatible service ID
    app.oauth_user_provider:
        alias: App\Security\OAuthUserProvider
        public: true

    # ──────────────────────────────────────────────────────────────
    # Gedmo listeners
    # ──────────────────────────────────────────────────────────────
    gedmo.listener.sortable:
        class: Gedmo\Sortable\SortableListener
        tags:
            - { name: doctrine.event_subscriber, connection: default }

    # ──────────────────────────────────────────────────────────────
    # Sonata Admin services (each Admin class)
    # ──────────────────────────────────────────────────────────────
    sonata.admin.country:
        class: PotagerBundle\Admin\CountryAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Country
              manager_type: orm
              group: 'Paramètres'
              label: 'Pays'
              show_in_dashboard: false
        public: true

    sonata.admin.city:
        class: PotagerBundle\Admin\CityAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\City
              manager_type: orm
              group: 'Paramètres'
              label: 'Ville/CP'
              show_in_dashboard: true
        public: true

    sonata.admin.administrateurs:
        class: PotagerBundle\Admin\AdministrateurAdmin
        tags:
            - name: sonata.admin
              model_class: App\Entity\User
              manager_type: orm
              group: 'Utilisateurs'
              label: 'Administrateurs'
        public: true

    sonata.admin.mode.livraison:
        class: PotagerBundle\Admin\ModeLivraisonAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Mode_livraison
              manager_type: orm
              group: 'Paramètres'
              label: 'Mode de livraison'
        public: true

    sonata.admin.moderamassage:
        class: PotagerBundle\Admin\ModeRamassageAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Mode_ramassage
              manager_type: orm
              group: 'Paramètres'
              label: 'Mode de ramassage'
        public: true

    sonata.admin.typepotager:
        class: PotagerBundle\Admin\TypePotagerAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Type_potager
              manager_type: orm
              group: 'Paramètres'
              label: 'Type potager'
        public: true

    sonata.admin.critere_avis:
        class: PotagerBundle\Admin\CritereAvisAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\CritereAvis
              manager_type: orm
              group: 'Paramètres'
              label: 'Critères des avis'
        public: true
        calls:

    sonata.admin.motif.refus:
        class: PotagerBundle\Admin\MotifRefusAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Motif_refus
              manager_type: orm
              group: 'Paramètres'
              label: 'Motifs refus de commandes'
        public: true

    sonata.admin.motifsignaler.potager:
        class: PotagerBundle\Admin\MotifSignalerPotagerAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\MotifSignalerPotager
              manager_type: orm
              group: 'Paramètres'
              label: 'Motifs de signaler potager'
        public: true

    sonata.admin.motifsignaler.avis:
        class: PotagerBundle\Admin\MotifSignalerAvisAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\MotifSignalerAvis
              manager_type: orm
              group: 'Paramètres'
              label: 'Motifs de signaler avis'
        public: true

    sonata.admin.slider.homepage:
        class: PotagerBundle\Admin\SliderAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Slider
              manager_type: orm
              group: 'Paramètres'
              label: 'Slider homepage'
        public: true
        calls:

    sonata.admin.potagerimg:
        class: PotagerBundle\Admin\PotagerimgAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Potagerimg
              manager_type: orm
              group: 'Paramètres'
              label: 'Images potager par défaut'
        public: true
        calls:

    sonata.admin.categorieproduit:
        class: PotagerBundle\Admin\CategorieAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Categorie
              manager_type: orm
              group: 'Paramètres Produits'
              label: 'Catégories de produits'
        public: true

    sonata.admin.produit:
        class: PotagerBundle\Admin\ProduitAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Produit
              manager_type: orm
              group: 'Paramètres Produits'
              label: 'Produits potager'
        public: true

    sonata.admin.type.qte:
        class: PotagerBundle\Admin\TypeQteAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Type_qte
              manager_type: orm
              group: 'Paramètres Produits'
              label: 'Typologie des quantités'
        public: true

    sonata.admin.categoriecms:
        class: PotagerBundle\Admin\CategorieCmsAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\CategorieCms
              manager_type: orm
              group: 'Gestion CMS'
              label: 'Catégories de pages'
        public: true

    sonata.admin.page:
        class: PotagerBundle\Admin\PageAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Page
              manager_type: orm
              group: 'Gestion CMS'
              label: 'Pages CMS'
        public: true

    sonata.admin.categoriefaq:
        class: PotagerBundle\Admin\CategorieFAQAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\CategorieFAQ
              manager_type: orm
              group: 'Gestion FAQ'
              label: 'Catégories FAQ'
        public: true
        calls:

    sonata.admin.faq:
        class: PotagerBundle\Admin\FAQAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\FAQ
              manager_type: orm
              group: 'Gestion FAQ'
              label: 'Questions/réponses'
        public: true
        calls:

    sonata.admin.formulaabonnament:
        class: PotagerBundle\Admin\FormuleAbonnementAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Formule_abonnement
              manager_type: orm
              group: 'Gestion des abonnements'
              label: 'Formules abonnement'
        public: true
        calls:

    sonata.admin.abonnement:
        class: PotagerBundle\Admin\AbonnementAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Abonnement
              manager_type: orm
              group: 'Gestion des abonnements'
              label: 'Abonnements jardiniers'
        public: true

    sonata.admin.abonnementparrainage:
        class: PotagerBundle\Admin\AbonnementParrainageAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Abonnement
              manager_type: orm
              group: 'Gestion des abonnements'
              label: 'Abonnements parrainés'
        public: true

    sonata.admin.codecadeau:
        class: PotagerBundle\Admin\CodeCadeauAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\CodeCadeau
              manager_type: orm
              group: 'Gestion des abonnements'
              label: 'Codes cadeaux'
        public: true

    sonata.admin.mode.paiement:
        class: PotagerBundle\Admin\ModePaiementAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Mode_paiement
              manager_type: orm
              group: 'Gestion des abonnements'
              label: 'Mode de paiement'
              show_in_dashboard: false
        public: true

    sonata.admin.dispo:
        class: PotagerBundle\Admin\DispoAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Dispo
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Dispo'
              show_in_dashboard: false
        public: true

    sonata.admin.jourferie:
        class: PotagerBundle\Admin\JourFerieAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\JourFerie
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Jour férié'
              show_in_dashboard: false
        public: true

    sonata.admin.imagepotager:
        class: PotagerBundle\Admin\ImagePotagerAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Image_potager
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Image potager'
              show_in_dashboard: false
        public: true

    sonata.admin.produitpotager:
        class: PotagerBundle\Admin\ProduitPotagerAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\ProduitPotager
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Produit potager'
              show_in_dashboard: false
        public: true

    sonata.admin.potager:
        class: PotagerBundle\Admin\PotagerAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Potager
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Liste des potagers'
        public: true

    sonata.admin.jardinier:
        class: PotagerBundle\Admin\JardinierAdmin
        tags:
            - name: sonata.admin
              model_class: App\Entity\User
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Liste des jardiniers'
        public: true

    sonata.admin.potagerparraine:
        class: PotagerBundle\Admin\PotagerParraineAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\PotagerParraine
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Potagers parrainés'
              show_in_dashboard: false
        public: true

    sonata.admin.potagersignale:
        class: PotagerBundle\Admin\PotagerSignaleAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\PotagerSignale
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Potagers signalés'
        public: true

    sonata.admin.commandedetail:
        class: PotagerBundle\Admin\CommandeDetailsAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Commande_details
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Détail commande'
              show_in_dashboard: false
        public: true

    sonata.admin.commande:
        class: PotagerBundle\Admin\CommandeAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Commande
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Commande'
              show_in_dashboard: false
        public: true

    sonata.admin.statistique_vue_potager:
        class: PotagerBundle\Admin\StatistiqueVuePotagerAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\StatistiqueVuePotager
              manager_type: orm
              group: 'Gestions des potagers'
              label: 'Statistiques des potagers'
              pager_type: simple
        public: true

    sonata.admin.acheteur:
        class: PotagerBundle\Admin\AcheteurAdmin
        tags:
            - name: sonata.admin
              model_class: App\Entity\User
              manager_type: orm
              group: 'Gestion des acheteurs'
              label: 'Liste des acheteurs'
        public: true

    sonata.admin.avis:
        class: PotagerBundle\Admin\AvisAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Avis
              manager_type: orm
              group: 'Gestion des avis'
              label: 'Avis sur potagers'
        public: true

    sonata.admin.avis.acheteur:
        class: PotagerBundle\Admin\AvisAcheteurAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Avis
              manager_type: orm
              group: 'Gestion des avis'
              label: 'Avis acheteurs'
        public: true

    sonata.admin.avissignale:
        class: PotagerBundle\Admin\AvisSignaleAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Avis
              manager_type: orm
              group: 'Gestion des avis'
              label: 'Traitement des signalés'
              show_in_dashboard: false
        public: true

    sonata.admin.parametre:
        class: PotagerBundle\Admin\ParametreAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Paramtre
              manager_type: orm
              group: 'Paramètres'
              label: 'Paramètres'
              show_in_dashboard: false
        public: true

    sonata.admin.contact:
        class: PotagerBundle\Admin\ContactAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Contact
              manager_type: orm
              group: 'Demande de contact'
              label: 'Demandes'
        public: true
        autowire: true

    sonata.admin.contact.archive:
        class: PotagerBundle\Admin\ContactArchiveAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Contact
              manager_type: orm
              group: 'Demande de contact'
              label: 'Demandes archivées'
        public: true
        autowire: true

    sonata.admin.parrainage:
        class: PotagerBundle\Admin\ParrainageAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Parrainage
              manager_type: orm
              group: 'Module parrainage'
              label: 'Liste des parrains'
              show_in_dashboard: false
        public: true

    sonata.admin.maintenance:
        class: PotagerBundle\Admin\MaintenanceAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\Maintenance
              manager_type: orm
              group: 'Maintenance'
              label: 'Maintenance'
        public: true

    sonata.admin.seo:
        class: PotagerBundle\Admin\SEOAdmin
        tags:
            - name: sonata.admin
              model_class: PotagerBundle\Entity\SEO
              manager_type: orm
              group: 'SEO'
              label: 'SEO'
        public: true
