services:
  _defaults:
    public: true
    autoconfigure: true

  PrestaShopBundle\Twig\LocaleExtension:
    public: false
    arguments:
      - '@=service("prestashop.adapter.legacy.context").getContext().language.date_format_lite'

  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.adapter.module.repository.module_repository").getActiveModulesPaths()'
    tags:
      - { name: twig.loader, priority: 1 }

  # Extensions

  prestashop.twig.extension.stringloader:
    class: Twig\Extension\StringLoaderExtension

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

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

  prestashop.twig.extension.data_formatter:
    class: PrestaShopBundle\Twig\DataFormatterExtension

  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"

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

  prestashop.bundle.twig.extension.documentation_link_provider_extension:
    class: 'PrestaShopBundle\Twig\Extension\DocumentationLinkExtension'
    autowire: true

  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"

  prestashop.twig.extension.path_with_back_url_extension:
    class: PrestaShopBundle\Twig\Extension\PathWithBackUrlExtension
    arguments:
      - '@twig.extension.routing'
      - '@PrestaShop\PrestaShop\Core\Util\Url\BackUrlProvider'
      - '@=service("request_stack") ? service("request_stack") : null'
    public: true

  prestashop.bundle.twig.extension.color_brightness_calculator_extension:
    class: PrestaShopBundle\Twig\Extension\ColorBrightnessCalculatorExtension
    autowire: true

  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()'

  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'
      - "@prestashop.core.localization.locale.repository"
      - '@=service("prestashop.adapter.legacy.context").getContext().language'
      - '@=service("prestashop.adapter.legacy.context").getContext().currency'

  prestashop.bundle.twig.extension.number_extension:
    class: 'PrestaShopBundle\Twig\Extension\NumberExtension'

  prestashop.twig.extension.multistore_components_extension:
    class: 'PrestaShopBundle\Twig\Extension\MultistoreComponentsExtension'
    arguments:
      - '@prestashop.core.admin.multistore'

  prestashop.bundle.twig.extension.multistore_url:
    class: 'PrestaShopBundle\Twig\Extension\MultistoreUrlExtension'
    arguments:
      - '@=service("request_stack")'

  prestashop.bundle.twig.extension.entity_search_extension:
    class: 'PrestaShopBundle\Twig\Extension\EntitySearchExtension'
