N°2060 [WIP] Initialisation of the portal application: Huge code cleanup

- Rename variables and methods in iTop files to match coding conventions
- Format code accordingly to coding conventions
- Add / update PHPDoc all over the place
- Suppress most of the warnings that did not have a big impact on code's logic
This commit is contained in:
Molkobain
2019-07-09 19:08:40 +02:00
parent c1258d0527
commit 9e9187b169
63 changed files with 3998 additions and 3088 deletions

View File

@@ -5,33 +5,35 @@ use Combodo\iTop\Portal\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
if (false === in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true))
{
echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.\PHP_SAPI.' SAPI'.\PHP_EOL;
}
set_time_limit(0);
if(!defined('APPROOT'))
if (!defined('APPROOT'))
{
if (file_exists(__DIR__ . '/../../../../approot.inc.php'))
if (file_exists(__DIR__.'/../../../../approot.inc.php'))
{
require_once __DIR__ . '/../../../../approot.inc.php'; // When in env-xxxx folder
require_once __DIR__.'/../../../../approot.inc.php'; // When in env-xxxx folder
}
else
{
require_once __DIR__ . '/../../../../../approot.inc.php'; // When in datamodels/x.x folder
require_once __DIR__.'/../../../../../approot.inc.php'; // When in datamodels/x.x folder
}
}
require_once APPROOT . 'lib/composer-vendor/autoload.php';
require_once APPROOT.'lib/composer-vendor/autoload.php';
if (!class_exists(Application::class)) {
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
if (!class_exists(Application::class))
{
throw new RuntimeException('You need to add "symfony/framework-bundle" as a Composer dependency.');
}
// Remove --portal_id from CLI params to avoid SF CLI conflicts
// Note: The parameter is needed when calling the bin/console to determine which portal to select
$aCleanedArgv = $_SERVER['argv'];
foreach($aCleanedArgv as $iArg => $sArg)
foreach ($aCleanedArgv as $iArg => $sArg)
{
if (preg_match('/^--portal_id=(.*)$/', $sArg, $aMatches))
{
@@ -40,17 +42,20 @@ foreach($aCleanedArgv as $iArg => $sArg)
}
}
$input = new ArgvInput($aCleanedArgv);
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
$oInput = new ArgvInput($aCleanedArgv);
if (null !== $sEnv = $oInput->getParameterOption(['--env', '-e'], null, true))
{
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $sEnv);
}
if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
if ($oInput->hasParameterOption('--no-debug', true))
{
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}
require_once MODULESROOT . 'itop-portal-base/portal/config/bootstrap.php';
require_once MODULESROOT.'itop-portal-base/portal/config/bootstrap.php';
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->run($input);
$oKernel = new Kernel($_SERVER['APP_ENV'], (bool)$_SERVER['APP_DEBUG']);
$oApplication = new Application($oKernel);
/** @noinspection PhpUnhandledExceptionInspection */
$oApplication->run($oInput);