From c22562f5cdb3db9482a7c6bc2398ebb12cbcfb8b Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Fri, 30 May 2014 14:57:19 +0200 Subject: [PATCH] [ticket/12620] Allow the user to define multiples environments PHPBB3-12620 --- phpBB/common.php | 5 ++++ phpBB/config/config_debug.yml | 2 ++ phpBB/config/config_productive.yml | 2 ++ phpBB/config/services.yml | 30 +++++++++---------- phpBB/config/{auth.yml => services_auth.yml} | 0 .../{avatar.yml => services_avatar.yml} | 0 .../{captcha.yml => services_captcha.yml} | 0 .../{console.yml => services_console.yml} | 0 .../{content.yml => services_content.yml} | 0 phpBB/config/{cron.yml => services_cron.yml} | 0 phpBB/config/{db.yml => services_db.yml} | 0 .../config/{event.yml => services_event.yml} | 0 phpBB/config/{feed.yml => services_feed.yml} | 0 ...sser.yml => services_mimetype_guesser.yml} | 0 ...fication.yml => services_notification.yml} | 0 .../{password.yml => services_password.yml} | 0 ...ilefield.yml => services_profilefield.yml} | 0 phpBB/config/{twig.yml => services_twig.yml} | 0 phpBB/config/{user.yml => services_user.yml} | 0 phpBB/includes/functions_install.php | 4 +-- phpBB/phpbb/di/extension/core.php | 2 +- 21 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 phpBB/config/config_debug.yml create mode 100644 phpBB/config/config_productive.yml rename phpBB/config/{auth.yml => services_auth.yml} (100%) rename phpBB/config/{avatar.yml => services_avatar.yml} (100%) rename phpBB/config/{captcha.yml => services_captcha.yml} (100%) rename phpBB/config/{console.yml => services_console.yml} (100%) rename phpBB/config/{content.yml => services_content.yml} (100%) rename phpBB/config/{cron.yml => services_cron.yml} (100%) rename phpBB/config/{db.yml => services_db.yml} (100%) rename phpBB/config/{event.yml => services_event.yml} (100%) rename phpBB/config/{feed.yml => services_feed.yml} (100%) rename phpBB/config/{mimetype_guesser.yml => services_mimetype_guesser.yml} (100%) rename phpBB/config/{notification.yml => services_notification.yml} (100%) rename phpBB/config/{password.yml => services_password.yml} (100%) rename phpBB/config/{profilefield.yml => services_profilefield.yml} (100%) rename phpBB/config/{twig.yml => services_twig.yml} (100%) rename phpBB/config/{user.yml => services_user.yml} (100%) diff --git a/phpBB/common.php b/phpBB/common.php index 0782bd7321..d4549dc2d4 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -29,6 +29,11 @@ $phpbb_class_loader->register(); $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx); extract($phpbb_config_php_file->get_all()); +if (!defined('ENVIRONMENT')) +{ + @define('ENVIRONMENT', 'productive'); +} + if (!defined('PHPBB_INSTALLED')) { // Redirect the user to the installer diff --git a/phpBB/config/config_debug.yml b/phpBB/config/config_debug.yml new file mode 100644 index 0000000000..6982aa4f83 --- /dev/null +++ b/phpBB/config/config_debug.yml @@ -0,0 +1,2 @@ +imports: + - { resource: services.yml } diff --git a/phpBB/config/config_productive.yml b/phpBB/config/config_productive.yml new file mode 100644 index 0000000000..6982aa4f83 --- /dev/null +++ b/phpBB/config/config_productive.yml @@ -0,0 +1,2 @@ +imports: + - { resource: services.yml } diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index f6dbae4a76..3f36a5178a 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -1,19 +1,19 @@ imports: - - { resource: auth.yml } - - { resource: avatar.yml } - - { resource: captcha.yml } - - { resource: console.yml } - - { resource: content.yml } - - { resource: cron.yml } - - { resource: db.yml } - - { resource: event.yml } - - { resource: feed.yml } - - { resource: mimetype_guesser.yml } - - { resource: notification.yml } - - { resource: password.yml } - - { resource: profilefield.yml } - - { resource: twig.yml } - - { resource: user.yml } + - { resource: services_auth.yml } + - { resource: services_avatar.yml } + - { resource: services_captcha.yml } + - { resource: services_console.yml } + - { resource: services_content.yml } + - { resource: services_cron.yml } + - { resource: services_db.yml } + - { resource: services_event.yml } + - { resource: services_feed.yml } + - { resource: services_mimetype_guesser.yml } + - { resource: services_notification.yml } + - { resource: services_password.yml } + - { resource: services_profilefield.yml } + - { resource: services_twig.yml } + - { resource: services_user.yml } - { resource: tables.yml } - { resource: parameters.yml } diff --git a/phpBB/config/auth.yml b/phpBB/config/services_auth.yml similarity index 100% rename from phpBB/config/auth.yml rename to phpBB/config/services_auth.yml diff --git a/phpBB/config/avatar.yml b/phpBB/config/services_avatar.yml similarity index 100% rename from phpBB/config/avatar.yml rename to phpBB/config/services_avatar.yml diff --git a/phpBB/config/captcha.yml b/phpBB/config/services_captcha.yml similarity index 100% rename from phpBB/config/captcha.yml rename to phpBB/config/services_captcha.yml diff --git a/phpBB/config/console.yml b/phpBB/config/services_console.yml similarity index 100% rename from phpBB/config/console.yml rename to phpBB/config/services_console.yml diff --git a/phpBB/config/content.yml b/phpBB/config/services_content.yml similarity index 100% rename from phpBB/config/content.yml rename to phpBB/config/services_content.yml diff --git a/phpBB/config/cron.yml b/phpBB/config/services_cron.yml similarity index 100% rename from phpBB/config/cron.yml rename to phpBB/config/services_cron.yml diff --git a/phpBB/config/db.yml b/phpBB/config/services_db.yml similarity index 100% rename from phpBB/config/db.yml rename to phpBB/config/services_db.yml diff --git a/phpBB/config/event.yml b/phpBB/config/services_event.yml similarity index 100% rename from phpBB/config/event.yml rename to phpBB/config/services_event.yml diff --git a/phpBB/config/feed.yml b/phpBB/config/services_feed.yml similarity index 100% rename from phpBB/config/feed.yml rename to phpBB/config/services_feed.yml diff --git a/phpBB/config/mimetype_guesser.yml b/phpBB/config/services_mimetype_guesser.yml similarity index 100% rename from phpBB/config/mimetype_guesser.yml rename to phpBB/config/services_mimetype_guesser.yml diff --git a/phpBB/config/notification.yml b/phpBB/config/services_notification.yml similarity index 100% rename from phpBB/config/notification.yml rename to phpBB/config/services_notification.yml diff --git a/phpBB/config/password.yml b/phpBB/config/services_password.yml similarity index 100% rename from phpBB/config/password.yml rename to phpBB/config/services_password.yml diff --git a/phpBB/config/profilefield.yml b/phpBB/config/services_profilefield.yml similarity index 100% rename from phpBB/config/profilefield.yml rename to phpBB/config/services_profilefield.yml diff --git a/phpBB/config/twig.yml b/phpBB/config/services_twig.yml similarity index 100% rename from phpBB/config/twig.yml rename to phpBB/config/services_twig.yml diff --git a/phpBB/config/user.yml b/phpBB/config/services_user.yml similarity index 100% rename from phpBB/config/user.yml rename to phpBB/config/services_user.yml diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 28cc603bdb..2be8e6e860 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -453,11 +453,11 @@ function phpbb_create_config_file_data($data, $dbms, $debug = false, $debug_cont if ($debug) { - $config_data .= "@define('DEBUG', true);\n"; + $config_data .= "@define('ENVIRONMENT', 'debug');\n"; } else { - $config_data .= "// @define('DEBUG', true);\n"; + $config_data .= "@define('ENVIRONMENT', 'productive');\n"; } if ($debug_container) diff --git a/phpBB/phpbb/di/extension/core.php b/phpBB/phpbb/di/extension/core.php index ca4fa5c082..d203cc7049 100644 --- a/phpBB/phpbb/di/extension/core.php +++ b/phpBB/phpbb/di/extension/core.php @@ -50,7 +50,7 @@ class core extends Extension public function load(array $config, ContainerBuilder $container) { $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->config_path))); - $loader->load('services.yml'); + $loader->load('config_' . ENVIRONMENT . '.yml'); } /**