# 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.html#use-parameters-for-application-configuration
parameters:
    app.locales: ['fr', 'en']

    kernelProjectDir: '%kernel.project_dir%'
    kernelPublicDir: '%kernelProjectDir%/public'
    kernelVarDir: '%kernelProjectDir%/var'

    google_recaptcha_site_key: '%env(GOOGLE_RECAPTCHA_SITE_KEY)%'
    locale: '%kernel.default_locale%'
    stripe_public_key: '%env(STRIPE_PUBLIC_KEY)%'
    stripe_secret_key: '%env(STRIPE_SECRET_KEY)%'
    stripe_webhook_key: '%env(STRIPE_WEBHOOK_KEY)%'

    app.path.images: '%kernelPublicDir%/images'
    app.path.realization: '%kernelVarDir%/images/realization'
    app.path.library: '%kernelVarDir%/images/library'
    app.path.gallery: '%kernelPublicDir%/images/gallery'
    app.path.activity: '%kernelPublicDir%/images/activity'
    app.path.room: '%kernelPublicDir%/images/room'
    app.path.uploads: '%kernelPublicDir%/uploads'

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

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

    Gedmo\Translatable\TranslatableListener:
        alias: 'stof_doctrine_extensions.listener.translatable'
        public: true

    #Pour l'installation du site
    App\SiteBundle\EventListener\InstallationListener:
        tags:
            - { name: kernel.event_listener, event: kernel.request }
    App\SiteBundle\StructuredData\OrganizationStructuredDataProvider:
        tags: ['app.seo.structured_data.global']
    App\SiteBundle\StructuredData\OrganizationStructuredData:
        arguments:
            $uploaderHelper: '@Vich\UploaderBundle\Templating\Helper\UploaderHelper'
    App\SiteBundle\Service\SiteInstaller:
        arguments: ['%kernelProjectDir%']

    App\EventSubscriber\LocaleSubscriber:
        arguments: ['%kernel.default_locale%']

    #Gestion des cycles de vies des Entity
    App\EventListener\EntityLifecycleListener:
        tags:
            - { name: doctrine.event_listener, event: prePersist }
            - { name: doctrine.event_listener, event: preUpdate }

    #Gestion du cache des images via Vich/Liip
    App\EventListener\ImageCacheListener:
        tags:
            - { name: doctrine.event_listener, event: preRemove }
            - { name: doctrine.event_listener, event: preUpdate }

    App\Service\Stripe\StripeService:
        arguments: ['%stripe_secret_key%']

    App\Service\Stripe\StripeWebhookService:
        arguments: ['%stripe_webhook_key%']

    App\FaqBundle\Resolver\FaqStructuredDataResolver:
        tags: ['app.seo.structured_data_resolver']

    #À la connexion d'un User, on met à jour la date de connexion de l'User
    App\UserBundle\EventListener\LoginListener:
        tags:
            - { name: kernel.event_listener, event: security.authentication.success, method: onSecurityAuthenticationSuccess }

    App\WeatherBundle\Service\WeatherService:
        arguments: ['%env(WEATHER_KEY)%']

    App\BookingBundle\Service\ActivityService:
        arguments: ['%app.locales%']


    App\LibraryBundle\Form\Admin\ItemWithParentType:
        arguments:
            $em: '@doctrine.orm.entity_manager'

    App\GalleryBundle\Namer\GalleryDirectoryNamer:
        public: true

    App\SeoBundle\DataCollector\StructuredDataCollector:
        tags:
        - { name: data_collector, id: 'app.seo.structured_data_collector', priority: 0 }
    App\SeoBundle\Resolver\StructuredDataResolverRegistry:
        calls:
            - method: register
              arguments:
                  - App\BookingBundle\Entity\Activity
                  - ['App\BookingBundle\Factory\ActivityStructuredDataFactory', 'create']
            - method: register
              arguments:
                  - App\BlogBundle\Entity\Article
                  - ['App\BlogBundle\Factory\ArticleStructuredDataFactory', 'create']
        arguments:
          $resolvers: !tagged_iterator 'app.seo.structured_data_resolver'
    App\SeoBundle\EventListener\GlobalStructuredDataListener:
        arguments:
            $providers: !tagged_iterator app.seo.structured_data.global
        tags:
            - { name: kernel.event_subscriber }