mirror of
https://github.com/shlinkio/shlink.git
synced 2025-04-01 14:24:26 +03:00
Created new entity_manager configuration, dropping old database first level config key
This commit is contained in:
parent
7b1b00901a
commit
270dbc6028
5 changed files with 42 additions and 21 deletions
|
@ -1,15 +0,0 @@
|
||||||
<?php
|
|
||||||
return [
|
|
||||||
|
|
||||||
'database' => [
|
|
||||||
'driver' => 'pdo_mysql',
|
|
||||||
'user' => env('DB_USER'),
|
|
||||||
'password' => env('DB_PASSWORD'),
|
|
||||||
'dbname' => env('DB_NAME', 'shlink'),
|
|
||||||
'charset' => 'utf8',
|
|
||||||
'driverOptions' => [
|
|
||||||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
];
|
|
20
config/autoload/entity-manager.global.php
Normal file
20
config/autoload/entity-manager.global.php
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
|
||||||
|
'entity_manager' => [
|
||||||
|
'orm' => [
|
||||||
|
'proxies_dir' => 'data/proxies',
|
||||||
|
],
|
||||||
|
'connection' => [
|
||||||
|
'driver' => 'pdo_mysql',
|
||||||
|
'user' => env('DB_USER'),
|
||||||
|
'password' => env('DB_PASSWORD'),
|
||||||
|
'dbname' => env('DB_NAME', 'shlink'),
|
||||||
|
'charset' => 'utf8',
|
||||||
|
'driverOptions' => [
|
||||||
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
|
@ -30,12 +30,14 @@ class EntityManagerFactory implements FactoryInterface
|
||||||
$globalConfig = $container->get('config');
|
$globalConfig = $container->get('config');
|
||||||
$isDevMode = isset($globalConfig['debug']) ? ((bool) $globalConfig['debug']) : false;
|
$isDevMode = isset($globalConfig['debug']) ? ((bool) $globalConfig['debug']) : false;
|
||||||
$cache = $container->has(Cache::class) ? $container->get(Cache::class) : new ArrayCache();
|
$cache = $container->has(Cache::class) ? $container->get(Cache::class) : new ArrayCache();
|
||||||
$dbConfig = isset($globalConfig['database']) ? $globalConfig['database'] : [];
|
$emConfig = isset($globalConfig['entity_manager']) ? $globalConfig['entity_manager'] : [];
|
||||||
|
$connecitonConfig = isset($emConfig['connection']) ? $emConfig['connection'] : [];
|
||||||
|
$ormConfig = isset($emConfig['orm']) ? $emConfig['orm'] : [];
|
||||||
|
|
||||||
return EntityManager::create($dbConfig, Setup::createAnnotationMetadataConfiguration(
|
return EntityManager::create($connecitonConfig, Setup::createAnnotationMetadataConfiguration(
|
||||||
['module/Core/src/Entity'],
|
isset($ormConfig['entities_paths']) ? $ormConfig['entities_paths'] : [],
|
||||||
$isDevMode,
|
$isDevMode,
|
||||||
'data/proxies',
|
isset($ormConfig['proxies_dir']) ? $ormConfig['proxies_dir'] : null,
|
||||||
$cache,
|
$cache,
|
||||||
false
|
false
|
||||||
));
|
));
|
||||||
|
|
|
@ -26,10 +26,12 @@ class EntityManagerFactoryTest extends TestCase
|
||||||
$sm = new ServiceManager(['services' => [
|
$sm = new ServiceManager(['services' => [
|
||||||
'config' => [
|
'config' => [
|
||||||
'debug' => true,
|
'debug' => true,
|
||||||
'database' => [
|
'entity_manager' => [
|
||||||
|
'connection' => [
|
||||||
'driver' => 'pdo_sqlite',
|
'driver' => 'pdo_sqlite',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
],
|
||||||
]]);
|
]]);
|
||||||
|
|
||||||
$em = $this->factory->__invoke($sm, EntityManager::class);
|
$em = $this->factory->__invoke($sm, EntityManager::class);
|
||||||
|
|
12
module/Core/config/entity-manager.config.php
Normal file
12
module/Core/config/entity-manager.config.php
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
return [
|
||||||
|
|
||||||
|
'entity_manager' => [
|
||||||
|
'orm' => [
|
||||||
|
'entities_paths' => [
|
||||||
|
__DIR__ . '/../src/Entity',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
|
||||||
|
];
|
Loading…
Add table
Reference in a new issue