Skip to content

Commit

Permalink
Added the data path global const to use it in all the places.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan Baidan committed Oct 24, 2023
1 parent 8ad3daa commit a841068
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 70 deletions.
5 changes: 3 additions & 2 deletions config/application.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
*
* @see https://github.com/zendframework/ZFTool
*/
$env = getenv('APPLICATION_ENV') ?: 'production';
$env = getenv('APP_ENV') ?: 'production';
$appConfDir = getenv('APP_CONF_DIR') ?: null;

defined('PROJECT_ROOT') or define('PROJECT_ROOT', __DIR__ . '/../');

if ($env !== 'testing') {
$confPaths = ['config/autoload/{,*.}{global,local}.php'];
}

$dataPath = 'data';
if (!empty($appConfDir)) {
$confPaths[] = $appConfDir . '/local.php';
Expand All @@ -25,6 +25,7 @@
}
}
}
defined('DATA_PATH') or define('DATA_PATH', $dataPath);

return [
'modules' => [
Expand Down
136 changes: 68 additions & 68 deletions config/autoload/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,56 @@
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 (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' => 'localhost',
'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' => 'localhost',
'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',
Expand All @@ -81,49 +81,49 @@
'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',
),
),
],
],
// https://github.com/beberlei/DoctrineExtensions/blob/master/config/mysql.yml
'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',
],
],
],
// END DOCTRINE CONF
);
];

0 comments on commit a841068

Please sign in to comment.