From ae8451e8372a0e0bf6ab8d30eb88f84eee668b17 Mon Sep 17 00:00:00 2001
From: Molkobain
Date: Fri, 28 Jun 2019 17:22:23 +0200
Subject: [PATCH] =?UTF-8?q?N=C2=B02060=20[WIP]=20Initialisation=20of=20the?=
=?UTF-8?q?=20portal=20application:?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- Default env. is now production.
- Debug mode through url param. is now available like in Silex version
---
datamodels/2.x/itop-portal-base/index.php | 6 ++++++
datamodels/2.x/itop-portal-base/portal/.env | 4 ++--
datamodels/2.x/itop-portal-base/portal/config/bootstrap.php | 6 +++---
.../portal/templates/errors/layout.html.twig | 2 +-
.../2.x/itop-portal-base/portal/templates/layout.html.twig | 2 +-
5 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/datamodels/2.x/itop-portal-base/index.php b/datamodels/2.x/itop-portal-base/index.php
index 38979ec9e..bf10e26dd 100644
--- a/datamodels/2.x/itop-portal-base/index.php
+++ b/datamodels/2.x/itop-portal-base/index.php
@@ -47,6 +47,12 @@ if(!defined('PORTAL_ID'))
define('PORTAL_ID', $sPortalId);
}
+// Set debug mode only when necessary
+if (utils::ReadParam('debug', 'false') === 'true')
+{
+ $_SERVER['APP_DEBUG'] = true;
+}
+
define('PORTAL_CACHE_PATH', utils::GetCachePath() . '/portals/' . PORTAL_ID . '/');
// Constants to be used in templates and others
diff --git a/datamodels/2.x/itop-portal-base/portal/.env b/datamodels/2.x/itop-portal-base/portal/.env
index 22257ab47..41326c5a4 100644
--- a/datamodels/2.x/itop-portal-base/portal/.env
+++ b/datamodels/2.x/itop-portal-base/portal/.env
@@ -14,8 +14,8 @@
# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration
###> symfony/framework-bundle ###
-APP_ENV=dev
-APP_SECRET=40ef8b29be00df19cec62edf08f73808
+#APP_ENV=prod
+#APP_SECRET=40ef8b29be00df19cec62edf08f73808
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS='^localhost|example\.com$'
###< symfony/framework-bundle ###
diff --git a/datamodels/2.x/itop-portal-base/portal/config/bootstrap.php b/datamodels/2.x/itop-portal-base/portal/config/bootstrap.php
index b620ffa29..72bfb0f1e 100644
--- a/datamodels/2.x/itop-portal-base/portal/config/bootstrap.php
+++ b/datamodels/2.x/itop-portal-base/portal/config/bootstrap.php
@@ -27,7 +27,7 @@ if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
}
if (null === $env = (isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null))) {
- $dotenv->populate(array('APP_ENV' => $env = 'dev'));
+ $dotenv->populate(array('APP_ENV' => $env = 'prod'));
}
if ('test' !== $env && file_exists($p = "$path.local")) {
@@ -46,6 +46,6 @@ if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
}
$_SERVER += $_ENV;
-$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = (isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null)) ?: 'dev';
-$_SERVER['APP_DEBUG'] = (isset($_SERVER['APP_DEBUG']) ? $_SERVER['APP_DEBUG'] : (isset($_ENV['APP_DEBUG']) ? $_ENV['APP_DEBUG'] : 'prod')) !== $_SERVER['APP_ENV'];
+$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = (isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null)) ?: 'prod';
+$_SERVER['APP_DEBUG'] = isset($_SERVER['APP_DEBUG']) ? $_SERVER['APP_DEBUG'] : (isset($_ENV['APP_DEBUG']) ? $_ENV['APP_DEBUG'] : ('prod' !== $_SERVER['APP_ENV']));
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
diff --git a/datamodels/2.x/itop-portal-base/portal/templates/errors/layout.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/errors/layout.html.twig
index f4e9295cf..72546d102 100644
--- a/datamodels/2.x/itop-portal-base/portal/templates/errors/layout.html.twig
+++ b/datamodels/2.x/itop-portal-base/portal/templates/errors/layout.html.twig
@@ -48,7 +48,7 @@
- {% if app['debug'] == true %}
+ {% if app['kernel'].debug == true %}
{% for aStep in debug_trace_steps %}
diff --git a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig
index d12c20f0b..c0f668f54 100644
--- a/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig
+++ b/datamodels/2.x/itop-portal-base/portal/templates/layout.html.twig
@@ -296,7 +296,7 @@
{% block pNavigationSideMenuLogo %}
{# This is a debug helper to know in which screen size we are #}
- {% if app['debug'] %}
+ {% if app['kernel'].debug == true %}
Debug : Taille XSSMMDLG
{% endif %}