<?php

namespace MintyPHP\Module\AddressBook;

use MintyPHP\App\AppContainer;
use MintyPHP\App\Container\ContainerRegistrar;
use MintyPHP\Module\AddressBook\Service\AddressBookService;
use MintyPHP\Service\Access\PermissionService;
use MintyPHP\Service\Access\RoleService;
use MintyPHP\Service\CustomField\CustomFieldRepositoryFactory;
use MintyPHP\Service\CustomField\UserCustomFieldValueService;
use MintyPHP\Service\Org\DepartmentService;
use MintyPHP\Service\Tenant\TenantScopeService;
use MintyPHP\Service\Tenant\TenantService;
use MintyPHP\Service\User\UserAccountService;
use MintyPHP\Service\User\UserAvatarService;
use MintyPHP\Service\User\UserProfileViewService;

final class AddressBookContainerRegistrar implements ContainerRegistrar
{
    public function register(AppContainer $container): void
    {
        $container->set(AddressBookAuthorizationPolicy::class, static fn (AppContainer $c): AddressBookAuthorizationPolicy => new AddressBookAuthorizationPolicy(
            $c->get(PermissionService::class)
        ));

        $container->set(AddressBookService::class, static fn (AppContainer $c): AddressBookService => new AddressBookService(
            $c->get(UserAccountService::class),
            $c->get(TenantService::class),
            $c->get(DepartmentService::class),
            $c->get(RoleService::class),
            $c->get(TenantScopeService::class),
            $c->get(UserCustomFieldValueService::class),
            $c->get(UserAvatarService::class),
            $c->get(UserProfileViewService::class),
            $c->get(CustomFieldRepositoryFactory::class)->createTenantCustomFieldOptionRepository()
        ));
    }
}
