Skip to content

Commit 183d0c1

Browse files
author
Martin Supiot
committed
Add default module value for session builder
1 parent 8f0ab56 commit 183d0c1

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/Service/AbstractServiceFactory.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,22 @@ abstract class AbstractServiceFactory implements FactoryInterface
3232
*/
3333
public function getPommOptions(ServiceLocatorInterface $sl)
3434
{
35+
// Get and check config
3536
$options = $sl->get('Config');
36-
$options = $options['pomm'];
37-
38-
if (null === $options) {
39-
throw new RuntimeException('Options could not be found in "pomm".');
37+
if (is_null($options) || !array_key_exists('pomm', $options)) {
38+
throw new \Exception('Options could not be found in "pomm".');
39+
}
40+
41+
// Define default module's values
42+
foreach ($options['pomm']['databases'] as &$database) {
43+
if (!array_key_exists('class:session_builder', $database)) {
44+
$database['class:session_builder'] = '\PommProject\ModelManager\SessionBuilder';
45+
}
4046
}
4147

48+
// Set options
49+
$options = $options['pomm'];
4250
$pommOptionsClass = $this->getOptionsClass();
43-
4451
return new $pommOptionsClass($options);
4552
}
4653

0 commit comments

Comments
 (0)