<?php

namespace MintyPHP\Module\AddressBook;

use MintyPHP\App\AppContainer;
use MintyPHP\App\Container\ContainerRegistrar;
use MintyPHP\Module\AddressBook\Service\AddressBookService;
use MintyPHP\Module\AddressBook\Service\AddressBookServicesFactory;
use MintyPHP\Service\CustomField\CustomFieldServicesFactory;
use MintyPHP\Service\Directory\DirectoryServicesFactory;
use MintyPHP\Service\Tenant\TenantScopeService;
use MintyPHP\Service\User\UserServicesFactory;

final class AddressBookContainerRegistrar implements ContainerRegistrar
{
    public function register(AppContainer $container): void
    {
        $container->set(AddressBookServicesFactory::class, static fn (AppContainer $c): AddressBookServicesFactory => new AddressBookServicesFactory(
            $c->get(UserServicesFactory::class),
            $c->get(DirectoryServicesFactory::class),
            $c->get(CustomFieldServicesFactory::class),
            $c->get(TenantScopeService::class)
        ));

        $container->set(AddressBookService::class, static fn (AppContainer $c): AddressBookService => $c
            ->get(AddressBookServicesFactory::class)
            ->createAddressBookService());
    }
}
