get(DatabaseConfig::class); $eventDispatcher = $container->get(EventDispatcher::class); $clock = $container->get(Clock::class); $timer = $container->get(Timer::class); // Get optional dependencies for profiling $logger = null; if ($databaseConfig->profilingConfig->enabled && $container->has(Logger::class)) { $logger = $container->get(Logger::class); } // Create platform for the database (defaulting to MySQL) $platform = new MySQLPlatform(); $db = new DatabaseManager( $databaseConfig, $platform, $timer, 'database/migrations', $clock, $logger, $eventDispatcher ); $container->singleton(DatabaseManager::class, $db); // Only register ConnectionInterface if not already registered if (! $container->has(ConnectionInterface::class)) { // Lazy connection - only create when requested $container->singleton(ConnectionInterface::class, fn () => $db->getConnection()); } // Get cache manager if caching is enabled $cacheManager = null; if ($databaseConfig->cacheConfig->enabled) { $cacheManager = $container->get(EntityCacheManager::class); } return EntityManagerFactory::create($db, $eventDispatcher, $clock, $container, $cacheManager); } }