# 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: 'fr'
    magento_default_store_id: 1
    magento_store_id: '%env(default:magento_default_store_id:MAGENTO_DEFAULT_STORE_ID)%'
    magento_url: '%env(MAGENTO_URL)%'
    magento_consumer_key: '%env(MAGENTO_CONSUMER_KEY)%'
    magento_secret_key: '%env(MAGENTO_SECRET_KEY)%'
    magento_access_token: '%env(MAGENTO_ACCESS_TOKEN)%'
    magento_access_token_secret: '%env(MAGENTO_ACCESS_TOKEN_SECRET)%'
    media_url: '%env(MEDIA_URL)%'
    application_url: '%env(APPLICATION_URL)%'
    calameo_api_key: '%env(CALAMEO_API_KEY)%'
    calameo_secret_key: '%env(CALAMEO_SECRET_KEY)%'
    calameo_endpoint: '%env(CALAMEO_ENDPOINT)%'
    magento_proxy: '%env(MAGENTO_PROXY)%'
    akeneo_api_key: '%env(AKENEO_API_KEY)%'
    akeneo_secret_key: '%env(AKENEO_SECRET_KEY)%'
    akeneo_username: '%env(AKENEO_USERNAME)%'
    akeneo_password: '%env(AKENEO_PASSWORD)%'
    akeneo_endpoint: '%env(AKENEO_ENDPOINT)%'

    version: 1.2.4

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

    App\EventListener\LoggerUser:
        arguments: ["@security.token_storage"]
        tags:
            -
                name: 'doctrine.event_listener'
                event: 'postUpdate'
                connection: 'default'

    App\EventListener\DomainListener:
        arguments: ["@security.token_storage"]
        tags:
            - { name: kernel.event_listener, event: kernel.request }

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

    App\Upload\DirectoryNamer:
        class: App\Upload\DirectoryNamer
        public: true
    
    settings:
        class: App\Service\Settings
        arguments: ['@doctrine.orm.entity_manager']
        public: true
    
    category_tree:
        class: App\Service\CategoryTree
        arguments: ['@doctrine.orm.entity_manager']
        public: false

    magento.connector:
        class: App\Service\MagentoConnector
        arguments: ['@logger']
        public: false
        tags: 
            - { name: monolog.logger, channel: "magento_log" }
    
    block.renderer:
        class: App\Service\BlockRenderer
        public: false
    
    magento.url:
        class: App\Service\MagentoUrl
        public: false
    
    magento.helper:
        class: App\Service\MagentoHelper
        public: false
    
    block.value_options:
        class: App\Service\BlockValueOptions
        public: false

    sonata.block.magento.cache:
        class: App\Service\MagentoCache
        public: true
        arguments: ['@templating']
        tags:
            - { name: sonata.block }

    admin.category:
        class: App\Admin\CategoryAdmin
        arguments: [~, App\Entity\Category, App\Controller\Admin\DefaultAdminController ]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Catégories' }
        calls:
            - [setTemplates, [{list: 'admin/list_entity_with_tree.html.twig', edit: 'admin/edit_entity_with_blocks.html.twig'}]]

    admin.job_group:
        class: App\Admin\JobGroupAdmin
        arguments: [~, App\Entity\JobGroup, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Regroupements Métiers' }

    admin.job:
        class: App\Admin\JobAdmin
        arguments: [~, App\Entity\Job, App\Controller\Admin\DefaultAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Métiers' }
        calls:
            - [setTemplate, ['edit', 'admin/edit_entity_with_blocks.html.twig']]

    admin.brand_group:
        class: App\Admin\BrandGroupAdmin
        arguments: [~, App\Entity\BrandGroup, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Regroupements Marques' }

    admin.brand:
        class: App\Admin\BrandAdmin
        arguments: [~, App\Entity\Brand, App\Controller\Admin\DefaultAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Marques' }
        calls:
            - [setTemplate, ['edit', 'admin/edit_entity_with_blocks.html.twig']]

    admin.page:
        class: App\Admin\PageAdmin
        arguments: [~, App\Entity\Page, App\Controller\Admin\DefaultAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Pages' }
        calls:
            - [setTemplate, ['edit', 'admin/edit_entity_with_blocks.html.twig']]
    
    admin.block_container:
        class: App\Admin\BlockContainerAdmin
        arguments: [~, App\Entity\BlockContainer, App\Controller\Admin\DefaultAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Vues' }
        calls:
            - [setTemplate, ['edit', 'admin/edit_block_container.html.twig']]

    admin.blog_post:
        class: App\Admin\BlogPostAdmin
        arguments: [~, App\Entity\BlogPost, App\Controller\Admin\DefaultAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Articles' }
    
    admin.blog_category:
        class: App\Admin\BlogCategoryAdmin
        arguments: [~, App\Entity\BlogCategory, App\Controller\Admin\DefaultAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Thématiques' }
    
    admin.export:
        class: App\Admin\ExportAdmin
        arguments: [~, App\Entity\Export, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Exports de contenu' }

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

    admin.color:
        class: App\Admin\ColorAdmin
        arguments: [~, App\Entity\Color, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Couleurs personnalisées' }

    admin.job_offer:
        class: App\Admin\JobOfferAdmin
        arguments: [~, App\Entity\JobOffer, App\Controller\Admin\DefaultAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: "Offres d'emploi" }

    admin.job_offer_tag:
        class: App\Admin\JobOfferTagAdmin
        arguments: [~, App\Entity\JobOfferTag, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Etiquettes' }

    admin.special_page:
        class: App\Admin\SpecialPageAdmin
        arguments: [~, App\Entity\SpecialPage, App\Controller\Admin\DefaultAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Pages configurables' }

    admin.menu_item:
        class: App\Admin\MenuItemAdmin
        arguments: [~, App\Entity\MenuItem, App\Controller\Admin\MenuItemAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Menu' }

    admin.menu_images:
        class: App\Admin\MenuImagesAdmin
        arguments: [~, App\Entity\MenuImages, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Menus Images' }

    admin.menu_link:
        class: App\Admin\MenuLinkAdmin
        arguments: [~, App\Entity\MenuLink, App\Controller\Admin\MenuItemAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Liens' }
    
    admin.user:
        class: App\Admin\UserAdmin
        arguments: [~, App\Entity\User, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Utilisateurs' }

    admin.website:
        class: App\Admin\WebsiteAdmin
        arguments: [~, App\Entity\Website, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Sites' }
      
    admin.calameo_book:
        class: App\Admin\CalameoBookAdmin
        arguments: [~, App\Entity\CalameoBook, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Catalogues' }

    admin.calameo_folder:
        class: App\Admin\CalameoFolderAdmin
        arguments: [~, App\Entity\CalameoFolder, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Dossiers' }
    
    admin.advert:
        class: App\Admin\AdvertAdmin
        arguments: [~, App\Entity\Advert, App\Controller\Admin\DefaultAdminController]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Offre promotionnelle' }

    admin.advert_menu:
        class: App\Admin\AdvertMenuAdmin
        arguments: [~, App\Entity\AdvertMenu, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Zone menu' }
    
    admin.question:
        class: App\Admin\QuestionAdmin
        arguments: [~, App\Entity\Question, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Questions' }
    
    admin.question_theme:
        class: App\Admin\QuestionThemeAdmin
        arguments: [~, App\Entity\QuestionTheme, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Thèmes' }
    
    admin.document:
        class: App\Admin\DocumentAdmin
        arguments: [~, App\Entity\Document, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Documents' }
    
    admin.advert_product:
        class: App\Admin\AdvertProductAdmin
        arguments: [~, App\Entity\AdvertProduct, ~]
        tags:
            - { name: sonata.admin, manager_type: orm, label: 'Fiche produit' }