BREAKING CHANGE: Requires PHP 8.5.0RC3 Changes: - Update Docker base image from php:8.4-fpm to php:8.5.0RC3-fpm - Enable ext-uri for native WHATWG URL parsing support - Update composer.json PHP requirement from ^8.4 to ^8.5 - Add ext-uri as required extension in composer.json - Move URL classes from Url.php85/ to Url/ directory (now compatible) - Remove temporary PHP 8.4 compatibility workarounds Benefits: - Native URL parsing with Uri\WhatWg\Url class - Better performance for URL operations - Future-proof with latest PHP features - Eliminates PHP version compatibility issues
50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Framework\Database;
|
|
|
|
use App\Framework\Async\AsyncService;
|
|
use App\Framework\Database\Config\DatabaseConfig;
|
|
use App\Framework\DateTime\Timer;
|
|
use App\Framework\DI\Container;
|
|
use App\Framework\DI\Initializer;
|
|
|
|
final readonly class ConnectionInitializer
|
|
{
|
|
public function __construct(
|
|
private ?AsyncService $asyncService = null,
|
|
private bool $enableAsync = true
|
|
) {
|
|
}
|
|
|
|
#[Initializer]
|
|
public function __invoke(Container $container): ConnectionInterface
|
|
{
|
|
// Check if EntityManagerInitializer already registered a connection
|
|
if ($container->has(DatabaseManager::class)) {
|
|
$connection = $container->get(DatabaseManager::class)->getConnection();
|
|
} else {
|
|
$databaseConfig = $container->get(DatabaseConfig::class);
|
|
$timer = $container->get(Timer::class);
|
|
|
|
// Create a simple database manager for connection only with minimal dependencies
|
|
$databaseManager = new DatabaseManager(
|
|
config: $databaseConfig,
|
|
platform: $databaseConfig->driverConfig->platform,
|
|
timer: $timer,
|
|
migrationsPath: 'database/migrations'
|
|
);
|
|
|
|
$connection = $databaseManager->getConnection();
|
|
}
|
|
|
|
// Automatically wrap with AsyncAwareConnection if AsyncService is available
|
|
if ($this->enableAsync && $this->asyncService !== null) {
|
|
return new AsyncAwareConnection($connection, $this->asyncService);
|
|
}
|
|
|
|
return $connection;
|
|
}
|
|
}
|