services:
    _defaults:
        public: true

    prestashop.twig.modules.loader:
        class: 'PrestaShopBundle\Twig\Locator\ModuleTemplateLoader'
        arguments:
          -
            'PrestaShop': ''
            'Product': '/Admin/Product'
            'Twig': '/Admin/TwigTemplateForm'
            'AdvancedParameters': '/Admin/Configure/AdvancedParameters'
            'ShopParameters': '/Admin/Configure/ShopParameters'
          - '@=service("prestashop.module_kernel.repository").getActiveModulesPaths()'
        tags:
          - { name: twig.loader, priority: 1}

    # Extensions

    prestashop.twig.extension.stringloader:
        class: Twig_Extension_StringLoader
        tags:
            - { name: twig.extension }

    prestashop.twig.extension.layout:
        class: PrestaShopBundle\Twig\LayoutExtension
        arguments:
          - "@prestashop.adapter.legacy.context"
          - "%kernel.environment%"
          - "@prestashop.adapter.legacy.configuration"
          - "@prestashop.adapter.data_provider.currency"
        tags:
            - { name: twig.extension }

    prestashop.twig.extension.translation:
        class: PrestaShopBundle\Twig\TranslationsExtension
        arguments: ["@service_container", "@router"]
        properties:
            logger: "@logger"
            translator: "@translator"
        tags:
            - { name: twig.extension }

    prestashop.twig.extension.data_formatter:
        class: PrestaShopBundle\Twig\DataFormatterExtension
        tags:
            - { name: twig.extension }

    prestashop.twig.extension.hook:
        class: PrestaShopBundle\Twig\HookExtension
        arguments:
            - "@prestashop.core.hook.dispatcher"
            - "@prestashop.adapter.data_provider.module"
            - "@=service('prestashop.adapter.legacy.context').getContext().employee?service('prestashop.core.admin.module.repository'):null"
        tags:
            - { name: twig.extension }

    prestashop.bundle.twig.extension.column:
        class: 'PrestaShopBundle\Twig\Extension\GridExtension'
        arguments:
            - '@twig'
            - '@prestashop.static_cache.adapter'
        tags:
            - { name: twig.extension }

    prestashop.bundle.twig.extension.documentation_link_provider_extension:
        class: 'PrestaShopBundle\Twig\Extension\DocumentationLinkExtension'
        arguments:
            - '@prestashop.core.util.helper_card.documentation_link_provider'
        tags:
            - { name: twig.extension }

    prestashop.twig.extension.context_iso_code_provider_extension:
      class: PrestaShopBundle\Twig\ContextIsoCodeProviderExtension
      arguments:
        - "@=service('prestashop.adapter.legacy.context').getContext().language ? service('prestashop.adapter.legacy.context').getContext().language.iso_code : 'en'"
      properties:
        logger: "@logger"
        translator: "@translator"
      tags:
        - { name: twig.extension }

    prestashop.twig.extension.path_with_back_url_extension:
      class: PrestaShopBundle\Twig\Extension\PathWithBackUrlExtension
      arguments:
        - '@twig.extension.routing'
        - '@prestashop.core.uti.back_url_provider'
        - '@=service("request_stack") ? service("request_stack") : null'
      public: true
      tags:
        - { name: twig.extension }

    prestashop.bundle.twig.extension.color_brightness_calculator_extension:
      class: PrestaShopBundle\Twig\Extension\ColorBrightnessCalculatorExtension
      arguments:
        - '@prestashop.core.util.color_brightness_calculator'
      tags:
        - { name: twig.extension }

    prestashop.bundle.twig.extension.js_router_metadata_extension:
      class: PrestaShopBundle\Twig\Extension\JsRouterMetadataExtension
      arguments:
        - '@=service("request_stack")'
        - '@=service("security.csrf.token_manager")'
        - '@=service("prestashop.user_provider").getUsername()'
      tags:
        - { name: twig.extension }

    prestashop.bundle.twig.extension.localization_extension:
      class: 'PrestaShopBundle\Twig\Extension\LocalizationExtension'
      arguments:
        - '@=service("prestashop.adapter.legacy.context").getContext().language.date_format_full'
        - '@=service("prestashop.adapter.legacy.context").getContext().language.date_format_lite'
      tags:
        - { name: twig.extension }

    prestashop.bundle.twig.extension.number_extension:
      class: 'PrestaShopBundle\Twig\Extension\NumberExtension'
      tags:
        - { name: twig.extension }
