Refatoring : Working state

This commit is contained in:
julien
2026-03-16 14:40:17 +01:00
parent d832d598fe
commit 115b079dfb
11 changed files with 691 additions and 504 deletions

View File

@@ -27,8 +27,12 @@ use App\Category\CategoryRepositoryInterface;
use App\Category\CategoryService;
use App\Category\CategoryServiceInterface;
use App\Category\Infrastructure\PdoCategoryRepository;
use App\Media\Domain\MediaStorageInterface;
use App\Media\Infrastructure\LocalMediaStorage;
use App\Media\Infrastructure\PdoMediaRepository;
use App\Media\MediaRepository;
use App\Media\MediaRepositoryInterface;
use App\Media\Application\MediaApplicationService;
use App\Media\MediaService;
use App\Media\MediaServiceInterface;
use App\Post\Application\PostApplicationService;
@@ -73,7 +77,7 @@ return [
UserServiceInterface::class => autowire(UserApplicationService::class),
CategoryServiceInterface::class => autowire(CategoryApplicationService::class),
CategoryRepositoryInterface::class => autowire(PdoCategoryRepository::class),
MediaRepositoryInterface::class => autowire(MediaRepository::class),
MediaRepositoryInterface::class => autowire(PdoMediaRepository::class),
PostRepositoryInterface::class => autowire(PdoPostRepository::class),
UserRepositoryInterface::class => autowire(PdoUserRepository::class),
LoginAttemptRepositoryInterface::class => autowire(LoginAttemptRepository::class),
@@ -82,6 +86,9 @@ return [
FlashServiceInterface::class => autowire(FlashService::class),
SessionManagerInterface::class => autowire(SessionManager::class),
HtmlSanitizerInterface::class => autowire(HtmlSanitizer::class),
MediaStorageInterface::class => factory(function (): MediaStorageInterface {
return new LocalMediaStorage(dirname(__DIR__) . '/public/media');
}),
// ── Infrastructure ────────────────────────────────────────────────────────
@@ -148,11 +155,15 @@ return [
}),
MediaServiceInterface::class => factory(
function (MediaRepositoryInterface $mediaRepository, PostRepositoryInterface $postRepository): MediaServiceInterface {
return new MediaService(
function (
MediaRepositoryInterface $mediaRepository,
PostRepositoryInterface $postRepository,
MediaStorageInterface $mediaStorage,
): MediaServiceInterface {
return new MediaApplicationService(
mediaRepository: $mediaRepository,
postRepository: $postRepository,
uploadDir: dirname(__DIR__) . '/public/media',
mediaStorage: $mediaStorage,
uploadUrl: '/media',
maxSize: (int) ($_ENV['UPLOAD_MAX_SIZE'] ?? 5 * 1024 * 1024),
);