# 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:
    locale: '%env(resolve:LOCALE)%'
    sber_pay_tax: '%env(resolve:SBER_PAY_TAX)%'
    yooKassa:
        key: '%env(resolve:YOOKASSA_KEY)%'
        shopID: '%env(resolve:YOOKASSA_SHOP_ID)%'
        returnURL: '%env(resolve:YOOKASSA_RETURN_URL)%'

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/Kernel.php'
            - '../src/Tests/'
    App\Entity\:
        resource: '../src/Entity'
        tags: ['controller.service_arguments']

    App\Services\SiteConfig\SiteConfig:
        class: App\Services\SiteConfig\SiteConfig
        arguments: ['%kernel.project_dir%', '@request_stack', '%kernel.default_locale%']
        public: true

    db_connection:
        class: Doctrine\DBAL\Connection
        factory: Doctrine\DBAL\DriverManager::getConnection
        arguments:
            $params:
                driver: 'pdo_pgsql'
                host:     "%env(resolve:DATABASE_HOST)%"
                port:     "%env(resolve:DATABASE_PORT)%"
                dbname:   "%env(resolve:DATABASE_NAME)%"
                user:     "%env(resolve:DATABASE_USER)%"
                password: "%env(resolve:DATABASE_PSW)%"
                charset:  UTF8

    app.dbprovider:
        class: App\Services\DbProvider
        arguments: ['@db_connection', '@security.token_storage', '@App\Services\SiteConfig\SiteConfig']

    App\Entity\Entity:
        class: App\Entity\Entity
        arguments: ['@app.dbprovider']

    app.auth.handler:
        class: App\Services\Security\AuthenticationHandler
        arguments: ['@router', '@request_stack']

    App\Services\Security\UserProvider:
        class: App\Services\Security\UserProvider
        arguments: ['@request_stack', '@security.user_password_hasher', '@App\Entity\UACEntity', '@twig']

    app.access.denied.controller:
        class: App\Services\Security\DeniedHandler
        arguments: ['@router']

    App\Services\Security\RouteVoter:
        class: App\Services\Security\RouteVoter
        tags: [security.voter]
        public: false

    form.Account:
        class: App\Form\AccountManager\Account
        arguments: ['@App\Entity\UACEntity', '@App\Entity\Land', '@security.token_storage', '@security.user_password_hasher']
        tags: [form.type]

    form.Range:
        class: App\Form\React\ReactRangeType
        arguments: ['@App\Services\SiteConfig\SiteConfig']
        tags: [form.type]

    form.Date:
        class: App\Form\React\ReactDateType
        arguments: ['@App\Services\SiteConfig\SiteConfig']
        tags: [form.type]

    App\Form\Budget\ItemEdit:
        class: App\Form\Budget\ItemEdit
        arguments: ['@App\Entity\Budget']
        tags: [form.type]

    App\Form\Budget\ItemCreate:
        class: App\Form\Budget\ItemCreate
        arguments: ['@App\Entity\Budget']
        tags: [form.type]

    App\Form\Land\Owner:
        class: App\Form\Land\Owner
        arguments: ['@App\Entity\Land']
        tags: [form.type]

    App\Form\Budget\Discount:
        class: App\Form\Budget\Discount
        arguments: ['@App\Entity\Land', '@App\Entity\Budget']
        tags: [form.type]

    App\Form\Budget\SpendingCreate:
        class: App\Form\Budget\SpendingCreate
        arguments: ['@App\Entity\Budget']
        tags: [form.type]

    App\Form\Budget\Charge:
        class: App\Form\Budget\Charge
        arguments: ['@App\Entity\Land']
        tags: [form.type]

    App\Form\ExtData\Edit:
        class: App\Form\ExtData\Edit
        arguments: ['@App\Entity\ExtData']
        tags: [form.type]

    App\Form\Electricity\AddBill:
        class: App\Form\Electricity\AddBill
        arguments: ['@App\Entity\Land']
        tags: [form.type]

    App\Form\Land\Debt:
        class: App\Form\Land\Debt
        arguments: ['@App\Entity\Land']
        tags: [form.type]

    App\Form\User\Payment:
        class: App\Form\User\Payment
        arguments: ['@App\Entity\User', '@App\Entity\Invoice']
        tags: [form.type]

    App\Form\MoneyMove\Edit:
        class: App\Form\MoneyMove\Edit
        arguments: ['@App\Entity\Land', '@App\Entity\Charges']
        tags: [form.type]
        
    App\Services\Twig\NumberFormat:
        class: App\Services\Twig\NumberFormat
        tags: [twig.extension]

    App\Services\YooKassa:
        class: App\Services\YooKassa
        arguments: ['%yooKassa%']

    App\Services\Sber:
        class: App\Services\Sber
