Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions phpmyfaq/src/phpMyFAQ/Instance/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
use phpMyFAQ\Configuration;
use phpMyFAQ\Core\Exception;
use phpMyFAQ\Instance\Database\DriverInterface;
use phpMyFAQ\Setup\Installation\SchemaInstaller;
use phpMyFAQ\Setup\Migration\QueryBuilder\DialectFactory;

/**
* Class Database
Expand Down Expand Up @@ -87,25 +89,23 @@ private function __construct(
/**
* Database factory.
*
* Returns a SchemaInstaller that uses the dialect-agnostic DatabaseSchema.
*
* @param Configuration $configuration phpMyFAQ configuration container
* @param string $type Database management system type
* @throws Exception
*/
public static function factory(Configuration $configuration, string $type): ?DriverInterface
{
if (str_starts_with($type, 'pdo_')) {
$class = 'phpMyFAQ\Instance\Database\Pdo' . ucfirst(substr($type, 4));
} else {
$class = 'phpMyFAQ\Instance\Database\\' . ucfirst($type);
try {
$dialect = DialectFactory::createForType(strtolower($type));
} catch (\InvalidArgumentException) {
throw new Exception('Invalid Database Type: ' . $type);
}

if (class_exists($class)) {
self::$driver = new $class($configuration);

return self::$driver;
}
self::$driver = new SchemaInstaller($configuration, $dialect);

throw new Exception('Invalid Database Type: ' . $type);
return self::$driver;
}

/**
Expand Down
8 changes: 0 additions & 8 deletions phpmyfaq/src/phpMyFAQ/Session/SessionWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,4 @@ public function remove(string $key): mixed
{
return $this->session->remove($key);
}

/**
* Get the underlying Symfony Session instance
*/
public function getSession(): Session
{
return $this->session;
}
}
Loading