Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make \VuFind\Db\ConnectionFactory easier to extend #30

Merged
merged 1 commit into from
Jun 7, 2024
Merged
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
19 changes: 17 additions & 2 deletions module/VuFind/src/VuFind/Db/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ class ConnectionFactory implements \Laminas\ServiceManager\Factory\FactoryInterf
*/
protected $container;

/**
* Configuration file name when used as a factory.
*
* @var string
*/
protected string $configName = 'config';

/**
* Connection wrapper class.
*
* @var string
*/
protected string $wrapperClass = \VuFind\Db\Connection::class;

/**
* Constructor
*
Expand Down Expand Up @@ -102,7 +116,8 @@ public function __invoke(
if (!empty($options)) {
throw new \Exception('Unexpected options sent to factory!');
}
$this->config = $container->get(\VuFind\Config\PluginManager::class)->get('config');
$this->config = $container->get(\VuFind\Config\PluginManager::class)
->get($this->configName);
$this->container = $container;
return $this->getConnection();
}
Expand Down Expand Up @@ -197,7 +212,7 @@ public function getConnectionFromOptions($options)
break;
}
*/
$options['wrapperClass'] = \VuFind\Db\Connection::class;
$options['wrapperClass'] = $this->wrapperClass;

// Set up database connection:
if (empty($this->container)) {
Expand Down
Loading