{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Container\/ServiceLocator.php",
"old_string": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\Container;\n\n\/**\n * Simple Service Locator for dependency management.\n *\n * This is a transitional solution for dependency injection until\n * a full DI container is introduced. It allows registering services\n * by interface and retrieving them throughout the application.\n *\n * Usage:\n * \/\/ Register a service",
"new_string": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\Container;\n\n\/\/ @responsibility: Service Locator für Dependency Management"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/Infrastructure\/Container\/ServiceLocator.php",
"oldString": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\Container;\n\n\/**\n * Simple Service Locator for dependency management.\n *\n * This is a transitional solution for dependency injection until\n * a full DI container is introduced. It allows registering services\n * by interface and retrieving them throughout the application.\n *\n * Usage:\n * \/\/ Register a service",
"newString": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\Container;\n\n\/\/ @responsibility: Service Locator für Dependency Management",
"originalFile": "<?php\n\ndeclare(strict_types=1);\n\nnamespace Infrastructure\\Container;\n\n\/**\n * Simple Service Locator for dependency management.\n *\n * This is a transitional solution for dependency injection until\n * a full DI container is introduced. It allows registering services\n * by interface and retrieving them throughout the application.\n *\n * Usage:\n * \/\/ Register a service\n * ServiceLocator::register(TaskRepositoryInterface::class, new TaskRepository());\n *\n * \/\/ Retrieve a service\n * $repo = ServiceLocator::get(TaskRepositoryInterface::class);\n *\n * @package Infrastructure\\Container\n *\/\nfinal class ServiceLocator\n{\n \/** @var array<class-string, object> *\/\n private static array $services = [];\n\n \/**\n * Register a service implementation for an interface.\n *\n * @param class-string $interface The interface or class name\n * @param object $implementation The concrete implementation\n *\/\n public static function register(string $interface, object $implementation): void\n {\n self::$services[$interface] = $implementation;\n }\n\n \/**\n * Get a registered service by interface.\n *\n * @param class-string $interface The interface or class name\n * @return object|null The service instance or null if not registered\n *\/\n public static function get(string $interface): ?object\n {\n return self::$services[$interface] ?? null;\n }\n\n \/**\n * Check if a service is registered.\n *\n * @param class-string $interface The interface or class name\n * @return bool True if registered\n *\/\n public static function has(string $interface): bool\n {\n return isset(self::$services[$interface]);\n }\n\n \/**\n * Get a service or create it using a factory.\n *\n * @param class-string $interface The interface or class name\n * @param callable(): object $factory Factory function to create the service\n * @return object The service instance\n *\/\n public static function getOrCreate(string $interface, callable $factory): object\n {\n if (!isset(self::$services[$interface])) {\n self::$services[$interface] = $factory();\n }\n\n return self::$services[$interface];\n }\n\n \/**\n * Clear all registered services (useful for testing).\n *\/\n public static function clear(): void\n {\n self::$services = [];\n }\n\n \/**\n * Get all registered service interfaces.\n *\n * @return array<class-string>\n *\/\n public static function getRegisteredInterfaces(): array\n {\n return array_keys(self::$services);\n }\n}\n",
"structuredPatch": [
{
"oldStart": 4,
"oldLines": 15,
"newStart": 4,
"newLines": 7,
"lines": [
" ",
" namespace Infrastructure\\Container;",
" ",
"-\/**",
"- * Simple Service Locator for dependency management.",
"- *",
"- * This is a transitional solution for dependency injection until",
"- * a full DI container is introduced. It allows registering services",
"- * by interface and retrieving them throughout the application.",
"- *",
"- * Usage:",
"- * \/\/ Register a service",
"+\/\/ @responsibility: Service Locator für Dependency Management",
" * ServiceLocator::register(TaskRepositoryInterface::class, new TaskRepository());",
" *",
" * \/\/ Retrieve a service"
]
}
],
"userModified": false,
"replaceAll": false
}
}