Commit e54fc079 authored by katbailey's avatar katbailey

Adding the default and slave database connections as services

parent 8122811d
......@@ -22,6 +22,7 @@ public function build(ContainerBuilder $container)
'tags' => array(),
'references' => array(),
'methods' => array(),
'arguments' => array(),
);
$references = array();
......@@ -31,6 +32,15 @@ public function build(ContainerBuilder $container)
$definition = new Definition($info['class'], $references);
if (isset($info['factory_class']) && isset($info['factory_method'])) {
$definition->setFactoryClass($info['factory_class']);
$definition->setFactoryMethod($info['factory_method']);
}
foreach ($info['arguments'] as $argument) {
$definition->addArgument($argument);
}
foreach($info['tags'] as $tag) {
$definition->addTag($tag);
}
......@@ -122,6 +132,18 @@ function getDefinitions() {
'references' => array('exception_controller'),
'tags' => array('kernel.event_subscriber')
),
'database' => array(
'class' => 'Drupal\Core\Database\Connection',
'factory_class' => 'Drupal\Core\Database\Database',
'factory_method' => 'getConnection',
'arguments' => array('default'),
),
'database.slave' => array(
'class' => 'Drupal\Core\Database\Connection',
'factory_class' => 'Drupal\Core\Database\Database',
'factory_method' => 'getConnection',
'arguments' => array('slave'),
),
);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment