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

72 lines
2.0 KiB
PHP

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