Skip to content

Commit a841068

Browse files
author
Ruslan Baidan
committed
Added the data path global const to use it in all the places.
1 parent 8ad3daa commit a841068

2 files changed

Lines changed: 71 additions & 70 deletions

File tree

config/application.config.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
*
66
* @see https://github.com/zendframework/ZFTool
77
*/
8-
$env = getenv('APPLICATION_ENV') ?: 'production';
8+
$env = getenv('APP_ENV') ?: 'production';
99
$appConfDir = getenv('APP_CONF_DIR') ?: null;
1010

1111
defined('PROJECT_ROOT') or define('PROJECT_ROOT', __DIR__ . '/../');
12-
1312
if ($env !== 'testing') {
1413
$confPaths = ['config/autoload/{,*.}{global,local}.php'];
1514
}
15+
1616
$dataPath = 'data';
1717
if (!empty($appConfDir)) {
1818
$confPaths[] = $appConfDir . '/local.php';
@@ -25,6 +25,7 @@
2525
}
2626
}
2727
}
28+
defined('DATA_PATH') or define('DATA_PATH', $dataPath);
2829

2930
return [
3031
'modules' => [

config/autoload/global.php

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,56 @@
1515
use Monarc\Core\Service\DoctrineCacheServiceFactory;
1616
use Monarc\Core\Service\DoctrineLoggerFactory;
1717

18-
$appconfdir = getenv('APP_CONF_DIR') ?? '';
19-
20-
$datapath = "data";
21-
if (!empty($appconfdir)) {
22-
$datapath = $appconfdir . '/data';
18+
$dataPath = 'data';
19+
if (defined('DATA_PATH')) {
20+
$dataPath = DATA_PATH;
21+
} elseif (getenv('APP_CONF_DIR')) {
22+
$dataPath = getenv('APP_CONF_DIR') . '/data';
2323
}
2424

25-
return array(
25+
return [
2626
// DOCTRINE CONF
27-
'service_manager' => array(
28-
'factories' => array(
27+
'service_manager' => [
28+
'factories' => [
2929
'doctrine.cache.mycache' => DoctrineCacheServiceFactory::class,
3030
'doctrine.monarc_logger' => DoctrineLoggerFactory::class,
31-
),
32-
),
33-
'doctrine' => array(
34-
'connection' => array(
35-
'orm_default' => array(
31+
],
32+
],
33+
'doctrine' => [
34+
'connection' => [
35+
'orm_default' => [
3636
'driverClass' => Driver::class,
37-
'params' => array(
37+
'params' => [
3838
'host' => 'localhost',
3939
'port' => 3306,
4040
'user' => 'root',
4141
'password' => '',
4242
'dbname' => 'monarc_common',
4343
'charset' => 'utf8',
44-
'driverOptions' => array(
44+
'driverOptions' => [
4545
PDO::ATTR_STRINGIFY_FETCHES => false,
4646
PDO::ATTR_EMULATE_PREPARES => false,
4747
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
48-
),
49-
),
50-
),
51-
'orm_cli' => array(
48+
],
49+
],
50+
],
51+
'orm_cli' => [
5252
'driverClass' => Driver::class,
53-
'params' => array(
53+
'params' => [
5454
'host' => 'localhost',
5555
'port' => 3306,
5656
'user' => 'root',
5757
'password' => '',
5858
'dbname' => 'monarc_cli',
5959
'charset' => 'utf8',
60-
'driverOptions' => array(
60+
'driverOptions' => [
6161
PDO::ATTR_STRINGIFY_FETCHES => false,
6262
PDO::ATTR_EMULATE_PREPARES => false,
6363
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
64-
),
65-
),
66-
),
67-
),
64+
],
65+
],
66+
],
67+
],
6868
/*'migrations_configuration' => array(
6969
'orm_default' => array(
7070
'name' => 'Monarc Migrations',
@@ -81,49 +81,49 @@
8181
'column' => 'version',
8282
),
8383
),*/
84-
'entitymanager' => array(
85-
'orm_default' => array(
86-
'connection' => 'orm_default',
87-
'configuration' => 'orm_default'
88-
),
89-
'orm_cli' => array(
90-
'connection' => 'orm_cli',
84+
'entitymanager' => [
85+
'orm_default' => [
86+
'connection' => 'orm_default',
87+
'configuration' => 'orm_default',
88+
],
89+
'orm_cli' => [
90+
'connection' => 'orm_cli',
9191
'configuration' => 'orm_cli',
92-
),
93-
),
92+
],
93+
],
9494
// https://github.com/beberlei/DoctrineExtensions/blob/master/config/mysql.yml
95-
'configuration' => array(
96-
'orm_default' => array(
97-
'metadata_cache' => 'mycache',
98-
'query_cache' => 'mycache',
99-
'result_cache' => 'mycache',
100-
'driver' => 'orm_default', // This driver will be defined later
101-
'generate_proxies' => true,
102-
'proxy_dir' => $datapath.'/DoctrineORMModule/Proxy',
103-
'proxy_namespace' => 'DoctrineORMModule\Proxy',
104-
'filters' => array(),
105-
'datetime_functions' => array(),
106-
'string_functions' => array(),
107-
'numeric_functions' => array(),
108-
'second_level_cache' => array(),
109-
'sql_logger' => 'doctrine.monarc_logger',
110-
),
111-
'orm_cli' => array(
112-
'metadata_cache' => 'mycache',
113-
'query_cache' => 'mycache',
114-
'result_cache' => 'mycache',
115-
'driver' => 'orm_cli', // This driver will be defined later
116-
'generate_proxies' => true,
117-
'proxy_dir' => $datapath.'/DoctrineORMModule/Proxy',
118-
'proxy_namespace' => 'DoctrineORMModule\Proxy',
119-
'filters' => array(),
120-
'datetime_functions' => array(),
121-
'string_functions' => array(),
122-
'numeric_functions' => array(),
123-
'second_level_cache' => array(),
124-
'sql_logger' => 'doctrine.monarc_logger',
125-
),
126-
),
127-
),
95+
'configuration' => [
96+
'orm_default' => [
97+
'metadata_cache' => 'mycache',
98+
'query_cache' => 'mycache',
99+
'result_cache' => 'mycache',
100+
'driver' => 'orm_default', // This driver will be defined later
101+
'generate_proxies' => true,
102+
'proxy_dir' => $dataPath . '/DoctrineORMModule/Proxy',
103+
'proxy_namespace' => 'DoctrineORMModule\Proxy',
104+
'filters' => [],
105+
'datetime_functions' => [],
106+
'string_functions' => [],
107+
'numeric_functions' => [],
108+
'second_level_cache' => [],
109+
'sql_logger' => 'doctrine.monarc_logger',
110+
],
111+
'orm_cli' => [
112+
'metadata_cache' => 'mycache',
113+
'query_cache' => 'mycache',
114+
'result_cache' => 'mycache',
115+
'driver' => 'orm_cli', // This driver will be defined later
116+
'generate_proxies' => true,
117+
'proxy_dir' => $dataPath . '/DoctrineORMModule/Proxy',
118+
'proxy_namespace' => 'DoctrineORMModule\Proxy',
119+
'filters' => [],
120+
'datetime_functions' => [],
121+
'string_functions' => [],
122+
'numeric_functions' => [],
123+
'second_level_cache' => [],
124+
'sql_logger' => 'doctrine.monarc_logger',
125+
],
126+
],
127+
],
128128
// END DOCTRINE CONF
129-
);
129+
];

0 commit comments

Comments
 (0)