From 497ab325f3d12817d09c228bb3e93991d9baee39 Mon Sep 17 00:00:00 2001 From: Ruslan Baidan Date: Tue, 24 Oct 2023 11:40:14 +0200 Subject: [PATCH] Added definition and usage of the DATA_PATH global const. --- config/application.config.php | 1 + config/autoload/global.php | 144 ++++++++++++++++---------------- config/autoload/global.php.dist | 12 ++- 3 files changed, 84 insertions(+), 73 deletions(-) diff --git a/config/application.config.php b/config/application.config.php index 0c546e6..0a8f7b6 100644 --- a/config/application.config.php +++ b/config/application.config.php @@ -25,6 +25,7 @@ if (!empty($appConfDir)) { } } } +defined('DATA_PATH') or define('DATA_PATH', $dataPath); return array( 'modules' => array( diff --git a/config/autoload/global.php b/config/autoload/global.php index 39366e9..f25f405 100755 --- a/config/autoload/global.php +++ b/config/autoload/global.php @@ -15,56 +15,56 @@ use Doctrine\DBAL\Driver\PDO\MySQL\Driver; use Monarc\Core\Service\DoctrineCacheServiceFactory; use Monarc\Core\Service\DoctrineLoggerFactory; -$appconfdir = getenv('APP_CONF_DIR') ?: ''; - -$datapath = "data"; -if( ! empty($appconfdir) ){ - $datapath = $appconfdir.'/data'; +$dataPath = 'data'; +if (defined('DATA_PATH')) { + $dataPath = DATA_PATH; +} elseif (!empty(getenv('APP_CONF_DIR'))) { + $dataPath = getenv('APP_CONF_DIR') . '/data'; } -return array( +return [ // DOCTRINE CONF - 'service_manager' => array( - 'factories' => array( + 'service_manager' => [ + 'factories' => [ 'doctrine.cache.mycache' => DoctrineCacheServiceFactory::class, 'doctrine.monarc_logger' => DoctrineLoggerFactory::class, - ), - ), - 'doctrine' => array( - 'connection' => array( - 'orm_default' => array( + ], + ], + 'doctrine' => [ + 'connection' => [ + 'orm_default' => [ 'driverClass' => Driver::class, - 'params' => array( + 'params' => [ 'host' => '127.0.0.1', 'port' => 3306, 'user' => 'root', 'password' => '', 'dbname' => 'monarc_common', 'charset' => 'utf8', - 'driverOptions' => array( + 'driverOptions' => [ PDO::ATTR_STRINGIFY_FETCHES => false, PDO::ATTR_EMULATE_PREPARES => false, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', - ), - ), - ), - 'orm_cli' => array( + ], + ], + ], + 'orm_cli' => [ 'driverClass' => Driver::class, - 'params' => array( + 'params' => [ 'host' => '127.0.0.1', 'port' => 3306, 'user' => 'root', 'password' => '', 'dbname' => 'monarc_cli', 'charset' => 'utf8', - 'driverOptions' => array( + 'driverOptions' => [ PDO::ATTR_STRINGIFY_FETCHES => false, PDO::ATTR_EMULATE_PREPARES => false, PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', - ), - ), - ), - ), + ], + ], + ], + ], /*'migrations_configuration' => array( 'orm_default' => array( 'name' => 'Monarc Migrations', @@ -81,53 +81,55 @@ return array( 'column' => 'version', ), ),*/ - 'entitymanager' => array( - 'orm_default' => array( - 'connection' => 'orm_default', - 'configuration' => 'orm_default' - ), - 'orm_cli' => array( - 'connection' => 'orm_cli', + 'entitymanager' => [ + 'orm_default' => [ + 'connection' => 'orm_default', + 'configuration' => 'orm_default', + ], + 'orm_cli' => [ + 'connection' => 'orm_cli', 'configuration' => 'orm_cli', - ), - ), - 'configuration' => array( - 'orm_default' => array( - 'metadata_cache' => 'mycache', - 'query_cache' => 'mycache', - 'result_cache' => 'mycache', - 'driver' => 'orm_default', // This driver will be defined later - 'generate_proxies' => true, - 'proxy_dir' => $datapath.'/DoctrineORMModule/Proxy', - 'proxy_namespace' => 'DoctrineORMModule\Proxy', - 'filters' => array(), - 'datetime_functions' => array(), - 'string_functions' => array(), - 'numeric_functions' => array(), - 'second_level_cache' => array(), - 'sql_logger' => 'doctrine.monarc_logger', - ), - 'orm_cli' => array( - 'metadata_cache' => 'mycache', - 'query_cache' => 'mycache', - 'result_cache' => 'mycache', - 'driver' => 'orm_cli', // This driver will be defined later - 'generate_proxies' => true, - 'proxy_dir' => $datapath.'/DoctrineORMModule/Proxy', - 'proxy_namespace' => 'DoctrineORMModule\Proxy', - 'filters' => array(), - 'datetime_functions' => array(), - 'string_functions' => array(), - 'numeric_functions' => array(), - 'second_level_cache' => array(), - 'sql_logger' => 'doctrine.monarc_logger', - ), - ), - ), + ], + ], + 'configuration' => [ + 'orm_default' => [ + 'metadata_cache' => 'mycache', + 'query_cache' => 'mycache', + 'result_cache' => 'mycache', + 'driver' => 'orm_default', // This driver will be defined later + 'generate_proxies' => true, + 'proxy_dir' => $dataPath . '/DoctrineORMModule/Proxy', + 'proxy_namespace' => 'DoctrineORMModule\Proxy', + 'filters' => [], + 'datetime_functions' => [], + 'string_functions' => [], + 'numeric_functions' => [], + 'second_level_cache' => [], + 'sql_logger' => 'doctrine.monarc_logger', + ], + 'orm_cli' => [ + 'metadata_cache' => 'mycache', + 'query_cache' => 'mycache', + 'result_cache' => 'mycache', + 'driver' => 'orm_cli', // This driver will be defined later + 'generate_proxies' => true, + 'proxy_dir' => $dataPath . '/DoctrineORMModule/Proxy', + 'proxy_namespace' => 'DoctrineORMModule\Proxy', + 'filters' => [], + 'datetime_functions' => [], + 'string_functions' => [], + 'numeric_functions' => [], + 'second_level_cache' => [], + 'sql_logger' => 'doctrine.monarc_logger', + ], + ], + ], - 'spool_path_create' => $datapath . '/json/create/',//default location path where the json file enabling the creation of the environment of the client should be generated - 'spool_path_delete' => $datapath . '/json/delete/', //default location path where the json file enabling the deletion of the environment of the client should be generated - 'spool_path_update' => $datapath . '/json/update/', + 'spool_path_create' => $dataPath . '/json/create/', + //default location path where the json file enabling the creation of the environment of the client should be generated + 'spool_path_delete' => $dataPath . '/json/delete/', + //default location path where the json file enabling the deletion of the environment of the client should be generated + 'spool_path_update' => $dataPath . '/json/update/', // END DOCTRINE CONF -); +]; diff --git a/config/autoload/global.php.dist b/config/autoload/global.php.dist index 3b059d5..d8e5122 100755 --- a/config/autoload/global.php.dist +++ b/config/autoload/global.php.dist @@ -10,6 +10,14 @@ * control, so do not include passwords or other sensitive information in this * file. */ + +$dataPath = 'data'; +if (defined('DATA_PATH')) { + $dataPath = DATA_PATH; +} elseif (!empty(getenv('APP_CONF_DIR'))) { + $dataPath = getenv('APP_CONF_DIR') . '/data'; +} + return array( // DOCTRINE CONF 'service_manager' => array( @@ -81,7 +89,7 @@ return array( 'result_cache' => 'mycache', 'driver' => 'orm_default', // This driver will be defined later 'generate_proxies' => true, - 'proxy_dir' => 'data/DoctrineORMModule/Proxy', + 'proxy_dir' => $dataPath .'data/DoctrineORMModule/Proxy', 'proxy_namespace' => 'DoctrineORMModule\Proxy', 'filters' => array(), 'datetime_functions' => array(), @@ -95,7 +103,7 @@ return array( 'result_cache' => 'mycache', 'driver' => 'orm_cli', // This driver will be defined later 'generate_proxies' => true, - 'proxy_dir' => 'data/DoctrineORMModule/Proxy', + 'proxy_dir' => $dataPath . 'data/DoctrineORMModule/Proxy', 'proxy_namespace' => 'DoctrineORMModule\Proxy', 'filters' => array(), 'datetime_functions' => array(),