mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-21 16:22:20 +02:00
N°8796 - Add PHP code style validation in iTop and extensions - format whole code base
This commit is contained in:
@@ -28,14 +28,10 @@ use Symfony\Component\Dotenv\Dotenv;
|
||||
require_once APPROOT.'/lib/autoload.php';
|
||||
|
||||
// Load current environment if necessary (typically from CLI as the app is not started yet)
|
||||
if (!defined('MODULESROOT'))
|
||||
{
|
||||
if (file_exists(__DIR__.'/../../../../approot.inc.php'))
|
||||
{
|
||||
if (!defined('MODULESROOT')) {
|
||||
if (file_exists(__DIR__.'/../../../../approot.inc.php')) {
|
||||
require_once __DIR__.'/../../../../approot.inc.php'; // When in env-xxxx folder
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
require_once __DIR__.'/../../../../../approot.inc.php'; // When in datamodels/x.x folder
|
||||
}
|
||||
require_once APPROOT.'/application/startup.inc.php';
|
||||
@@ -62,7 +58,7 @@ if (!class_exists(Dotenv::class)) {
|
||||
}
|
||||
|
||||
if (null === $sEnv = (isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null))) {
|
||||
$oDotenv->populate(array('APP_ENV' => $sEnv = 'prod'));
|
||||
$oDotenv->populate(['APP_ENV' => $sEnv = 'prod']);
|
||||
}
|
||||
|
||||
if ('test' !== $sEnv && file_exists($sPathDist = "$sPath.local")) {
|
||||
@@ -83,31 +79,27 @@ if (!class_exists(Dotenv::class)) {
|
||||
$_SERVER += $_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';
|
||||
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int)$_SERVER['APP_DEBUG'] || filter_var(
|
||||
$_SERVER['APP_DEBUG'],
|
||||
FILTER_VALIDATE_BOOLEAN
|
||||
) ? '1' : '0';
|
||||
|
||||
if ($_SERVER['APP_DEBUG'])
|
||||
{
|
||||
if ($_SERVER['APP_DEBUG']) {
|
||||
umask(0000);
|
||||
|
||||
if (class_exists(Debug::class))
|
||||
{
|
||||
if (class_exists(Debug::class)) {
|
||||
Debug::enable();
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_ENV['PORTAL_ID']))
|
||||
{
|
||||
if (isset($_ENV['PORTAL_ID'])) {
|
||||
// Nothing to do
|
||||
}
|
||||
// Note: Default value is set to "false" to differentiate an empty value from a non given parameter
|
||||
elseif ($sPortalId = utils::ReadParam('portal_id', false, true))
|
||||
{
|
||||
elseif ($sPortalId = utils::ReadParam('portal_id', false, true)) {
|
||||
|
||||
$_ENV['PORTAL_ID'] = $sPortalId;
|
||||
}
|
||||
elseif (defined('PORTAL_ID'))
|
||||
{
|
||||
} elseif (defined('PORTAL_ID')) {
|
||||
$_ENV['PORTAL_ID'] = PORTAL_ID;
|
||||
@trigger_error(
|
||||
sprintf(
|
||||
@@ -118,16 +110,14 @@ elseif (defined('PORTAL_ID'))
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($_ENV['PORTAL_ID']))
|
||||
{
|
||||
if (empty($_ENV['PORTAL_ID'])) {
|
||||
echo "Missing argument 'portal_id'";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Make sure that the PORTAL_ID constant is also defined
|
||||
// Note: This is widely used in extensions, snippets and all
|
||||
if (!defined('PORTAL_ID'))
|
||||
{
|
||||
if (!defined('PORTAL_ID')) {
|
||||
define('PORTAL_ID', $_ENV['PORTAL_ID']);
|
||||
}
|
||||
|
||||
@@ -138,4 +128,4 @@ $_ENV['COMBODO_CONF_APP_ICON_URL'] = MetaModel::GetConfig()->Get('app_icon_url')
|
||||
$_ENV['COMBODO_MODULES_ABSOLUTE_URL'] = utils::GetAbsoluteUrlModulesRoot();
|
||||
$_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_URL'] = utils::GetAbsoluteUrlModulesRoot().'itop-portal-base/portal/public/';
|
||||
$_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_PATH'] = MODULESROOT.'/itop-portal-base/portal/public/';
|
||||
$_ENV['COMBODO_PORTAL_INSTANCE_ABSOLUTE_URL'] = utils::GetAbsoluteUrlModulesRoot().$_ENV['PORTAL_ID'].'/';
|
||||
$_ENV['COMBODO_PORTAL_INSTANCE_ABSOLUTE_URL'] = utils::GetAbsoluteUrlModulesRoot().$_ENV['PORTAL_ID'].'/';
|
||||
|
||||
@@ -7,4 +7,4 @@ return static function (ContainerConfigurator $container) {
|
||||
// kernel.secret
|
||||
$container->parameters()->set('kernel.secret', MetaModel::GetConfig()->Get('application.secret'));
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2024 Combodo SAS
|
||||
*
|
||||
|
||||
@@ -58,26 +58,25 @@ $oKPI->ComputeAndReport('Load portal lists definition');
|
||||
// A dedicated listener 'CssFromSassCompiler' exists to compile files again when by-passing HTTP cache.
|
||||
// This is to keep developers comfort when tuning the SCSS files.
|
||||
$oKPI = new ExecutionKPI();
|
||||
$aImportPaths = array($_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_PATH'].'css/');
|
||||
$aImportPaths = [$_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_PATH'].'css/'];
|
||||
$aPortalConf = $container->getParameter('combodo.portal.instance.conf');
|
||||
foreach ($aPortalConf['properties']['themes'] as $sKey => $value)
|
||||
{
|
||||
if (!is_array($value))
|
||||
{
|
||||
$aPortalConf['properties']['themes'][$sKey] = utils::GetCSSFromSASS('env-'.utils::GetCurrentEnvironment().'/'.$value,
|
||||
$aImportPaths);
|
||||
}
|
||||
else
|
||||
{
|
||||
$aValues = array();
|
||||
foreach ($value as $sSubValue)
|
||||
{
|
||||
$aValues[] = utils::GetCSSFromSASS('env-'.utils::GetCurrentEnvironment().'/'.$sSubValue,
|
||||
$aImportPaths);
|
||||
foreach ($aPortalConf['properties']['themes'] as $sKey => $value) {
|
||||
if (!is_array($value)) {
|
||||
$aPortalConf['properties']['themes'][$sKey] = utils::GetCSSFromSASS(
|
||||
'env-'.utils::GetCurrentEnvironment().'/'.$value,
|
||||
$aImportPaths
|
||||
);
|
||||
} else {
|
||||
$aValues = [];
|
||||
foreach ($value as $sSubValue) {
|
||||
$aValues[] = utils::GetCSSFromSASS(
|
||||
'env-'.utils::GetCurrentEnvironment().'/'.$sSubValue,
|
||||
$aImportPaths
|
||||
);
|
||||
}
|
||||
$aPortalConf['properties']['themes'][$sKey] = $aValues;
|
||||
}
|
||||
}
|
||||
$oKPI->ComputeAndReport('Generating CSS files');
|
||||
|
||||
$container->setParameter('combodo.portal.instance.conf', $aPortalConf);
|
||||
$container->setParameter('combodo.portal.instance.conf', $aPortalConf);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2024 Combodo SAS
|
||||
*
|
||||
@@ -24,8 +25,7 @@ use Symfony\Component\Routing\Route;
|
||||
$oRouteCollection = new RouteCollection();
|
||||
|
||||
$aRoutes = ItopExtensionsExtraRoutes::GetRoutes();
|
||||
foreach ($aRoutes as $aRoute)
|
||||
{
|
||||
foreach ($aRoutes as $aRoute) {
|
||||
$aRoute['values'] = (isset($aRoute['values'])) ? $aRoute['values'] : [];
|
||||
$aRoute['asserts'] = (isset($aRoute['asserts'])) ? $aRoute['asserts'] : [];
|
||||
|
||||
@@ -42,4 +42,4 @@ foreach ($aRoutes as $aRoute)
|
||||
);
|
||||
}
|
||||
|
||||
return $oRouteCollection;
|
||||
return $oRouteCollection;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2024 Combodo SAS
|
||||
*
|
||||
@@ -45,4 +46,4 @@ return static function (ContainerConfigurator $oContainer) {
|
||||
->autoconfigure();
|
||||
}
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user