# Sellora — Application service configuration.
#
# Module-specific services live under modules/<ModuleName>/config/services.yaml
# and are auto-loaded by Sellora\Kernel::configureContainer.

parameters:
    sellora.shop.name: '%env(SHOP_NAME)%'
    sellora.shop.url: '%env(SHOP_URL)%'
    sellora.shop.default_locale: '%env(SHOP_DEFAULT_LOCALE)%'
    sellora.shop.default_currency: '%env(SHOP_DEFAULT_CURRENCY)%'
    sellora.theme.active: '%env(SHOP_ACTIVE_THEME)%'
    sellora.theme.dir: '%kernel.project_dir%/themes'
    sellora.modules.dir: '%kernel.project_dir%/modules'
    sellora.media.dir: '%kernel.project_dir%/public/media'

services:
    _defaults:
        autowire: true
        autoconfigure: true
        public: false

    Sellora\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'
            - '../src/Core/Hook/DependencyInjection/'
            - '../src/Core/Module/DependencyInjection/'
            - '../src/Core/Hook/Hooks.php'
            - '../src/Core/Hook/HookEvent.php'
            - '../src/Core/Hook/Attribute/'
            - '../src/Core/Hook/HookSubscriberInterface.php'
            - '../src/Core/Module/Exception/'
            - '../src/Core/Module/ModuleContext.php'
            - '../src/Core/Money/'

    # Bundled themes — modules ship their own services.yaml under
    # modules/<Name>/config/services.yaml (auto-imported by the kernel).
    Sellora\Theme\Default\DefaultTheme: ~
    Sellora\Theme\Elegance\EleganceTheme: ~

    # Auto-tag interfaces.
    _instanceof:
        Sellora\Core\Hook\HookSubscriberInterface:
            tags: ['sellora.hook_subscriber']
        Sellora\Core\Module\ModuleInterface:
            tags: ['sellora.module']
        Sellora\Core\Theme\ThemeInterface:
            tags: ['sellora.theme']
        Sellora\Core\Payment\PaymentGatewayInterface:
            tags: ['sellora.payment_gateway']
        Sellora\Core\Shipping\ShippingMethodInterface:
            tags: ['sellora.shipping_method']

    Sellora\Core\Theme\ThemeManager:
        arguments:
            $themes: !tagged_iterator sellora.theme
            $activeName: '%sellora.theme.active%'
            $themesDir: '%sellora.theme.dir%'

    Sellora\Core\Theme\Twig\ThemeAwareTwigConfigurator:
        arguments:
            $modulesDir: '%sellora.modules.dir%'

    Sellora\Core\Module\ModuleManager:
        arguments:
            $modules: !tagged_iterator sellora.module
            $services: '@service_container'
            $modulesDir: '%sellora.modules.dir%'

    Sellora\Core\Cart\CartContext:
        arguments:
            $defaultCurrency: '%sellora.shop.default_currency%'
            $defaultLocale: '%sellora.shop.default_locale%'
