You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
doctrine/config/default.php

60 lines
1.6 KiB
PHTML

7 years ago
<?php
namespace BitCommunism\Doctrine;
use DI\Container;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use function DI\add;
7 years ago
use function DI\factory;
use function DI\get;
use function DI\string;
7 years ago
return array_merge(
[
'marx.calls' => add([
'doctrine' => function (EntityManager $em, $arguments) {
$connection = $em->getResponsibleEntityManager($arguments[0] ?? 'default');
7 years ago
7 years ago
return ConsoleRunner::createHelperSet($connection);
},
]),
7 years ago
'doctrine.debug' => get('debug'),
'doctrine.single-connection' => false,
7 years ago
'em' => get(EntityManager::class),
7 years ago
EntityManager::class => factory(function (Container $c) {
$contextAware = $c->get(ContextAwareEntityManager::class);
7 years ago
7 years ago
if ($c->get('doctrine.single-connection')) {
return $contextAware->getResponsibleEntityManager('default');
}
7 years ago
7 years ago
return $contextAware;
}),
],
connections([
'example' => [
'connection' => [
'driver' => 'pdo_mysql',
'hostname' => 'localhost',
'password' => '',
'user' => 'root',
'dbname' => 'ipsum',
],
'entity-paths' => realpath(__DIR__ . '/../src/Entity')
],
'default' => [
7 years ago
'connection' => add([
'driver' => 'pdo_mysql',
'hostname' => 'localhost',
'password' => '',
'user' => 'root',
]),
'entity-paths' => add([
string('{basedir}/src/Entity')
]),
7 years ago
]
])
);