# 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: en
    app_locales: en|de|it|fr|es|ru|ar|hu|pt_BR|sv|ja|sk

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.
        public: false       # Allows optimizing the container by removing unused services; this also means
                            # fetching services directly from the container via $container->get() won't work.
                            # The best practice is to be explicit about your dependencies anyway.
        bind:
            $projectDirectory: '%kernel.project_dir%'

    # 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,Constants.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']

    # ================================================================================
    # APPLICATION CORE
    # ================================================================================

    App\EventSubscriber\RedirectToLocaleSubscriber:
        arguments: ['@router', '%app_locales%', '%locale%']

    App\Repository\WidgetRepository:
        arguments:
            $widgets: '%kimai.widgets%'

    App\Controller\DashboardController:
        arguments:
            $dashboard: '%kimai.dashboard%'

    App\Configuration\LanguageFormattings:
        arguments: ['%kimai.languages%']

    App\Configuration\TimesheetConfiguration:
        arguments:
            $settings: '%kimai.timesheet%'

    App\Configuration\CalendarConfiguration:
        arguments:
            $settings: '%kimai.calendar%'

    App\Configuration\FormConfiguration:
        arguments:
            $settings: '%kimai.defaults%'

    App\Configuration\SystemConfiguration:
        arguments:
            $settings: '%kimai.config%'

    App\Configuration\ThemeConfiguration:
        arguments:
            $settings: '%kimai.theme%'

    App\Configuration\LdapConfiguration:
        arguments: ['%kimai.ldap%']

    App\Utils\MPdfConverter:
        arguments: ['%kernel.cache_dir%']

    App\Plugin\PluginManager:
        arguments: [!tagged kimai.plugin]

    App\Export\ServiceExport:
        arguments: [!tagged export.renderer]

    App\Widget\WidgetService:
        arguments:
            $renderer: !tagged widget.renderer

    # ================================================================================
    # DATABASE
    # ================================================================================

    # updates timesheet records and apply configured rate & rounding rules
    App\Doctrine\TimesheetSubscriber:
        class: App\Doctrine\TimesheetSubscriber
        arguments: [!tagged timesheet.calculator]
        tags:
            - { name: doctrine.event_subscriber, priority: 50 }

    # make sure, that sqlite supports foreign keys and cascade deletes
    App\Doctrine\SqliteSessionInitSubscriber:
        class: App\Doctrine\SqliteSessionInitSubscriber
        tags:
            - { name: doctrine.event_listener, event: postConnect }

    # ================================================================================
    # FORMS
    # ================================================================================

    App\Form\Type\LanguageType:
        arguments: ['%app_locales%']

    # ================================================================================
    # THEME
    # ================================================================================

    KevinPapst\AdminLTEBundle\Helper\ContextHelper:
        alias: admin_lte_theme.context_helper

    # ================================================================================
    # TIMESHEET RECORD CALCULATOR
    # ================================================================================

    App\Timesheet\Calculator\DurationCalculator:
        arguments: ['%kimai.timesheet.rounding%']

    App\Timesheet\Calculator\RateCalculator:
        arguments: ['%kimai.timesheet.rates%']

    # ================================================================================
    # SECURITY & VOTER
    # ================================================================================

    App\Security\RoleService:
        arguments: ['%security.role_hierarchy.roles%']

    App\Security\RolePermissionManager:
        arguments: ['%kimai.permissions%']

    # ================================================================================
    # LDAP
    # ================================================================================

    kimai_ldap.security.authentication.provider:
        class: App\Ldap\LdapAuthenticationProvider
        arguments: ['@App\Security\UserChecker', '', '', '', '@App\Configuration\LdapConfiguration', '%security.authentication.hide_user_not_found%']

    # ================================================================================
    # REPOSITORIES
    # ================================================================================

    App\Repository\TimesheetRepository:
        class:     Doctrine\ORM\EntityRepository
        factory:   ['@doctrine.orm.entity_manager', getRepository]
        arguments: ['App\Entity\Timesheet']

    App\Repository\UserRepository:
        class:     Doctrine\ORM\EntityRepository
        factory:   ['@doctrine.orm.entity_manager', getRepository]
        arguments: ['App\Entity\User']

    App\Repository\ActivityRepository:
        class:     Doctrine\ORM\EntityRepository
        factory:   ['@doctrine.orm.entity_manager', getRepository]
        arguments: ['App\Entity\Activity']

    App\Repository\ProjectRepository:
        class:     Doctrine\ORM\EntityRepository
        factory:   ['@doctrine.orm.entity_manager', getRepository]
        arguments: ['App\Entity\Project']

    App\Repository\TagRepository:
        class:     Doctrine\ORM\EntityRepository
        factory:   ['@doctrine.orm.entity_manager', getRepository]
        arguments: ['App\Entity\Tag']

    App\Repository\CustomerRepository:
        class:     Doctrine\ORM\EntityRepository
        factory:   ['@doctrine.orm.entity_manager', getRepository]
        arguments: ['App\Entity\Customer']

    App\Repository\InvoiceTemplateRepository:
        class:     Doctrine\ORM\EntityRepository
        factory:   ['@doctrine.orm.entity_manager', getRepository]
        arguments: ['App\Entity\InvoiceTemplate']

    App\Repository\ConfigurationRepository:
        class:     Doctrine\ORM\EntityRepository
        factory:   ['@doctrine.orm.entity_manager', getRepository]
        arguments: ['App\Entity\Configuration']

    App\Repository\InvoiceDocumentRepository:
        class: App\Repository\InvoiceDocumentRepository
        arguments: ['%kimai.invoice.documents%']