61 lines
1.8 KiB
PHP
61 lines
1.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Domain\SmartLink\DI;
|
|
|
|
use App\Domain\SmartLink\Repositories\ClickEventRepository;
|
|
use App\Domain\SmartLink\Repositories\SmartLinkRepository;
|
|
use App\Domain\SmartLink\Services\ClickStatisticsService;
|
|
use App\Domain\SmartLink\Services\ClickTrackingService;
|
|
use App\Domain\SmartLink\Services\SmartLinkService;
|
|
use App\Framework\Database\ConnectionInterface;
|
|
use App\Framework\DI\Container;
|
|
use App\Framework\DI\Initializer;
|
|
use App\Infrastructure\SmartLink\Repositories\DatabaseClickEventRepository;
|
|
|
|
/**
|
|
* SmartLink Domain Service Registration
|
|
*
|
|
* Registers all SmartLink domain services in the DI container.
|
|
*/
|
|
final readonly class SmartLinkServiceInitializer
|
|
{
|
|
#[Initializer]
|
|
public function __invoke(Container $container): void
|
|
{
|
|
// Repository Bindings
|
|
$container->singleton(
|
|
ClickEventRepository::class,
|
|
fn(Container $c) => new DatabaseClickEventRepository(
|
|
$c->get(ConnectionInterface::class)
|
|
)
|
|
);
|
|
|
|
// SmartLink Management Service
|
|
$container->singleton(
|
|
SmartLinkService::class,
|
|
fn(Container $c) => new SmartLinkService(
|
|
$c->get(SmartLinkRepository::class)
|
|
)
|
|
);
|
|
|
|
// Click Tracking Service
|
|
$container->singleton(
|
|
ClickTrackingService::class,
|
|
fn(Container $c) => new ClickTrackingService(
|
|
$c->get(ClickEventRepository::class),
|
|
$c->get(SmartLinkRepository::class)
|
|
)
|
|
);
|
|
|
|
// Click Statistics Service (NEW - for Analytics Dashboard)
|
|
$container->singleton(
|
|
ClickStatisticsService::class,
|
|
fn(Container $c) => new ClickStatisticsService(
|
|
$c->get(ClickEventRepository::class)
|
|
)
|
|
);
|
|
}
|
|
}
|