mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-21 08:12:26 +02:00
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:
@@ -1,63 +1,101 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// Disable PhpUnhandledExceptionInspection as the exception handling is made by the file including this one
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
|
||||
use Symfony\Component\Debug\Debug;
|
||||
use Symfony\Component\Dotenv\Dotenv;
|
||||
|
||||
require_once APPROOT.'/lib/composer-vendor/autoload.php';
|
||||
|
||||
// Load current environment if necessary
|
||||
if(!defined('MODULESROOT'))
|
||||
if (!defined('MODULESROOT'))
|
||||
{
|
||||
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 . '/application/startup.inc.php';
|
||||
require_once APPROOT.'/application/startup.inc.php';
|
||||
}
|
||||
|
||||
// Load cached env vars if the .env.local.php file exists
|
||||
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
|
||||
if (is_array($env = @include dirname(__DIR__).'/.env.local.php')) {
|
||||
$_ENV += $env;
|
||||
} elseif (!class_exists(Dotenv::class)) {
|
||||
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
|
||||
} else {
|
||||
$path = dirname(__DIR__).'/.env';
|
||||
$dotenv = new Dotenv(false);
|
||||
if (is_array($sEnv = @include dirname(__DIR__).'/.env.local.php'))
|
||||
{
|
||||
$_ENV += $sEnv;
|
||||
}
|
||||
elseif (!class_exists(Dotenv::class))
|
||||
{
|
||||
throw new RuntimeException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$sPath = dirname(__DIR__).'/.env';
|
||||
$oDotenv = new Dotenv(false);
|
||||
|
||||
// load all the .env files
|
||||
if (method_exists($dotenv, 'loadEnv')) {
|
||||
$dotenv->loadEnv($path);
|
||||
} else {
|
||||
// fallback code in case your Dotenv component is not 4.2 or higher (when loadEnv() was added)
|
||||
// load all the .env files
|
||||
if (method_exists($oDotenv, 'loadEnv'))
|
||||
{
|
||||
$oDotenv->loadEnv($sPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
// fallback code in case your Dotenv component is not 4.2 or higher (when loadEnv() was added)
|
||||
|
||||
if (file_exists($path) || !file_exists($p = "$path.dist")) {
|
||||
$dotenv->load($path);
|
||||
} else {
|
||||
$dotenv->load($p);
|
||||
}
|
||||
if (file_exists($sPath) || !file_exists($sPathDist = "$sPath.dist"))
|
||||
{
|
||||
$oDotenv->load($sPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
$oDotenv->load($sPathDist);
|
||||
}
|
||||
|
||||
if (null === $env = (isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null))) {
|
||||
$dotenv->populate(array('APP_ENV' => $env = 'prod'));
|
||||
}
|
||||
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'));
|
||||
}
|
||||
|
||||
if ('test' !== $env && file_exists($p = "$path.local")) {
|
||||
$dotenv->load($p);
|
||||
$env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : $env);
|
||||
}
|
||||
if ('test' !== $sEnv && file_exists($sPathDist = "$sPath.local"))
|
||||
{
|
||||
$oDotenv->load($sPathDist);
|
||||
$sEnv = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : $sEnv);
|
||||
}
|
||||
|
||||
if (file_exists($p = "$path.$env")) {
|
||||
$dotenv->load($p);
|
||||
}
|
||||
if (file_exists($sPathDist = "$sPath.$sEnv"))
|
||||
{
|
||||
$oDotenv->load($sPathDist);
|
||||
}
|
||||
|
||||
if (file_exists($p = "$path.$env.local")) {
|
||||
$dotenv->load($p);
|
||||
}
|
||||
}
|
||||
if (file_exists($sPathDist = "$sPath.$sEnv.local"))
|
||||
{
|
||||
$oDotenv->load($sPathDist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set debug mode only when necessary
|
||||
@@ -69,27 +107,30 @@ if (utils::ReadParam('debug', 'false') === 'true')
|
||||
$_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(
|
||||
@@ -101,7 +142,7 @@ elseif(defined('PORTAL_ID'))
|
||||
);
|
||||
}
|
||||
|
||||
if(empty($_ENV['PORTAL_ID']))
|
||||
if (empty($_ENV['PORTAL_ID']))
|
||||
{
|
||||
echo "Missing argument 'portal_id'";
|
||||
exit;
|
||||
@@ -110,7 +151,7 @@ if(empty($_ENV['PORTAL_ID']))
|
||||
// Env. vars to be used in templates and others
|
||||
$_ENV['COMBODO_CURRENT_ENVIRONMENT'] = utils::GetCurrentEnvironment();
|
||||
$_ENV['COMBODO_ABSOLUTE_URL'] = utils::GetAbsoluteUrlAppRoot();
|
||||
$_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_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'].'/';
|
||||
@@ -1,7 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
return [
|
||||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
|
||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true],
|
||||
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
|
||||
Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
|
||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true],
|
||||
];
|
||||
|
||||
@@ -20,52 +20,60 @@
|
||||
*
|
||||
*/
|
||||
|
||||
// Disable PhpUnhandledExceptionInspection as the exception handling is made by the file including this one
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
|
||||
// Loading file
|
||||
use Combodo\iTop\Portal\DependencyInjection\SilexCompatBootstrap\PortalXmlConfiguration\Basic;
|
||||
use Combodo\iTop\Portal\DependencyInjection\SilexCompatBootstrap\PortalXmlConfiguration\Forms;
|
||||
use Combodo\iTop\Portal\DependencyInjection\SilexCompatBootstrap\PortalXmlConfiguration\Lists;
|
||||
|
||||
// Note: ModuleDesign service is not available yet as this script is processed before service generation,
|
||||
// Note: ModuleDesign service is not available yet as this script is processed before services generation,
|
||||
// that's why we have to instantiate it manually.
|
||||
$oModuleDesign = new ModuleDesign($_ENV['PORTAL_ID']);
|
||||
|
||||
// TODO: The following code needs to be refactored to more independent and atomic services.
|
||||
|
||||
// Load portal conf. such as properties, themes, templates, ...
|
||||
// Append into %combodo.portal.instance.conf%
|
||||
$oBasicCompat = new Basic($oModuleDesign);
|
||||
$oBasicCompat->Process($container);
|
||||
|
||||
// Load portal forms definition
|
||||
// Append into %combodo.portal.instance.conf%
|
||||
$oFormsCompat = new Forms($oModuleDesign);
|
||||
$oFormsCompat->Process($container);
|
||||
|
||||
// Load portal lists definition
|
||||
// Append into %combodo.portal.instance.conf%
|
||||
$oListsCompat = new Lists($oModuleDesign);
|
||||
$oListsCompat->Process($container);
|
||||
|
||||
// - Generating CSS files
|
||||
// Generating CSS files
|
||||
$aImportPaths = array($_ENV['COMBODO_PORTAL_BASE_ABSOLUTE_PATH'].'css/');
|
||||
$aPortalConf = $container->getParameter('combodo.portal.instance.conf');
|
||||
foreach ($aPortalConf['properties']['themes'] as $key => $value)
|
||||
foreach ($aPortalConf['properties']['themes'] as $sKey => $value)
|
||||
{
|
||||
if (!is_array($value))
|
||||
{
|
||||
$aPortalConf['properties']['themes'][$key] = $_ENV['COMBODO_ABSOLUTE_URL'].utils::GetCSSFromSASS('env-'.utils::GetCurrentEnvironment().'/'.$value, $aImportPaths);
|
||||
$aPortalConf['properties']['themes'][$sKey] = $_ENV['COMBODO_ABSOLUTE_URL'].utils::GetCSSFromSASS('env-'.utils::GetCurrentEnvironment().'/'.$value,
|
||||
$aImportPaths);
|
||||
}
|
||||
else
|
||||
{
|
||||
$aValues = array();
|
||||
foreach ($value as $sSubValue)
|
||||
{
|
||||
$aValues[] = $_ENV['COMBODO_ABSOLUTE_URL'].utils::GetCSSFromSASS('env-'.utils::GetCurrentEnvironment().'/'.$sSubValue, $aImportPaths);
|
||||
$aValues[] = $_ENV['COMBODO_ABSOLUTE_URL'].utils::GetCSSFromSASS('env-'.utils::GetCurrentEnvironment().'/'.$sSubValue,
|
||||
$aImportPaths);
|
||||
}
|
||||
$aPortalConf['properties']['themes'][$key] = $aValues;
|
||||
$aPortalConf['properties']['themes'][$sKey] = $aValues;
|
||||
}
|
||||
}
|
||||
$container->setParameter('combodo.portal.instance.conf', $aPortalConf);
|
||||
|
||||
//TODO: The following needs to be refactored
|
||||
//session messages
|
||||
// Session messages
|
||||
$aAllMessages = array();
|
||||
if ((array_key_exists('obj_messages', $_SESSION)) && (!empty($_SESSION['obj_messages'])))
|
||||
{
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
framework:
|
||||
cache:
|
||||
# Put the unique name of your app here: the prefix seed
|
||||
# is used to compute stable namespaces for cache keys.
|
||||
#prefix_seed: your_vendor_name/app_name
|
||||
cache:
|
||||
# Put the unique name of your app here: the prefix seed
|
||||
# is used to compute stable namespaces for cache keys.
|
||||
#prefix_seed: your_vendor_name/app_name
|
||||
|
||||
# The app cache caches to the filesystem by default.
|
||||
# Other options include:
|
||||
# The app cache caches to the filesystem by default.
|
||||
# Other options include:
|
||||
|
||||
# Redis
|
||||
#app: cache.adapter.redis
|
||||
#default_redis_provider: redis://localhost
|
||||
# Redis
|
||||
#app: cache.adapter.redis
|
||||
#default_redis_provider: redis://localhost
|
||||
|
||||
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
|
||||
#app: cache.adapter.apcu
|
||||
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
|
||||
#app: cache.adapter.apcu
|
||||
|
||||
# Namespaced pools use the above "app" backend by default
|
||||
#pools:
|
||||
#my.dedicated.cache: ~
|
||||
# Namespaced pools use the above "app" backend by default
|
||||
#pools:
|
||||
#my.dedicated.cache: ~
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: true
|
||||
router:
|
||||
strict_requirements: true
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
framework:
|
||||
secret: '%env(APP_SECRET)%'
|
||||
#default_locale: en
|
||||
#csrf_protection: true
|
||||
#http_method_override: true
|
||||
secret: '%env(APP_SECRET)%'
|
||||
#default_locale: en
|
||||
#csrf_protection: true
|
||||
#http_method_override: true
|
||||
|
||||
# Enables session support. Note that the session will ONLY be started if you read or write from it.
|
||||
# Remove or comment this section to explicitly disable session support.
|
||||
session:
|
||||
handler_id: ~
|
||||
# Enables session support. Note that the session will ONLY be started if you read or write from it.
|
||||
# Remove or comment this section to explicitly disable session support.
|
||||
session:
|
||||
handler_id: ~
|
||||
|
||||
#esi: true
|
||||
#fragments: true
|
||||
php_errors:
|
||||
log: true
|
||||
#esi: true
|
||||
#fragments: true
|
||||
php_errors:
|
||||
log: true
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: ~
|
||||
router:
|
||||
strict_requirements: ~
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
framework:
|
||||
test: true
|
||||
session:
|
||||
storage_id: session.storage.mock_file
|
||||
test: true
|
||||
session:
|
||||
storage_id: session.storage.mock_file
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
framework:
|
||||
router:
|
||||
strict_requirements: true
|
||||
router:
|
||||
strict_requirements: true
|
||||
|
||||
@@ -3,4 +3,4 @@ web_profiler:
|
||||
intercept_redirects: false
|
||||
|
||||
framework:
|
||||
profiler: { collect: false }
|
||||
profiler: { collect: falseS }
|
||||
@@ -1,4 +1,4 @@
|
||||
twig:
|
||||
default_path: '%combodo.modules.absolute_path%'
|
||||
debug: '%kernel.debug%'
|
||||
strict_variables: '%kernel.debug%'
|
||||
default_path: '%combodo.modules.absolute_path%'
|
||||
debug: '%kernel.debug%'
|
||||
strict_variables: '%kernel.debug%'
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
_errors:
|
||||
resource: '@TwigBundle/Resources/config/routing/errors.xml'
|
||||
prefix: /_error
|
||||
resource: '@TwigBundle/Resources/config/routing/errors.xml'
|
||||
prefix: /_error
|
||||
|
||||
@@ -1,34 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Bruno DA SILVA, working for Combodo
|
||||
* Date: 30/01/19
|
||||
* Time: 18:06
|
||||
* Copyright (C) 2013-2019 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Portal\Routing\ItopExtensionsExtraRoutes;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use App\Controller\BlogController;
|
||||
|
||||
$oRouteCollection = new RouteCollection();
|
||||
|
||||
$aRoutes = \Combodo\iTop\Portal\Routing\ItopExtensionsExtraRoutes::getRoutes();
|
||||
$aRoutes = ItopExtensionsExtraRoutes::GetRoutes();
|
||||
foreach ($aRoutes as $aRoute)
|
||||
{
|
||||
$aRoute['values'] = (isset($aRoute['values'])) ? $aRoute['values'] : [];
|
||||
$aRoute['asserts'] = (isset($aRoute['asserts'])) ? $aRoute['asserts'] : [];
|
||||
|
||||
$routes = new RouteCollection();
|
||||
|
||||
foreach ($aRoutes as $route) {
|
||||
$route['values'] = (isset($route['values'])) ? $route['values'] : [];
|
||||
$route['asserts'] = (isset($route['asserts'])) ? $route['asserts'] : [];
|
||||
|
||||
$routes->add(
|
||||
$route['bind'],
|
||||
new Route(
|
||||
$route['pattern'],
|
||||
array_merge(
|
||||
['_controller' => $route['callback']],
|
||||
$route['values']
|
||||
),
|
||||
$route['asserts']
|
||||
)
|
||||
);
|
||||
$oRouteCollection->add(
|
||||
$aRoute['bind'],
|
||||
new Route(
|
||||
$aRoute['pattern'],
|
||||
array_merge(
|
||||
['_controller' => $aRoute['callback']],
|
||||
$aRoute['values']
|
||||
),
|
||||
$aRoute['asserts']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $routes;
|
||||
return $oRouteCollection;
|
||||
@@ -19,115 +19,115 @@
|
||||
# Files in the packages/ subdirectory configure your dependencies.
|
||||
|
||||
imports:
|
||||
- { resource: "legacy_silex_compat_layer.php" }
|
||||
- { resource: "legacy_silex_compat_layer.php" }
|
||||
|
||||
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
|
||||
parameters:
|
||||
# Replace default url generator service
|
||||
router.options.generator_base_class: Combodo\iTop\Portal\Routing\UrlGenerator
|
||||
# Replace default url generator service
|
||||
router.options.generator_base_class: Combodo\iTop\Portal\Routing\UrlGenerator
|
||||
|
||||
# Used in templates
|
||||
combodo.current_environment: '%env(string:COMBODO_CURRENT_ENVIRONMENT)%'
|
||||
combodo.absolute_url: '%env(string:COMBODO_ABSOLUTE_URL)%'
|
||||
combodo.modules.absolute_url: '%env(string:COMBODO_MODULES_ABSOLUTE_URL)%'
|
||||
combodo.modules.absolute_path: !php/const MODULESROOT
|
||||
combodo.portal.base.absolute_url: '%env(string:COMBODO_PORTAL_BASE_ABSOLUTE_URL)%'
|
||||
combodo.portal.base.absolute_path: '%env(string:COMBODO_PORTAL_BASE_ABSOLUTE_PATH)%'
|
||||
combodo.portal.instance.absolute_url: '%env(string:COMBODO_PORTAL_INSTANCE_ABSOLUTE_URL)%'
|
||||
combodo.portal.instance.id: '%env(string:PORTAL_ID)%'
|
||||
# Used in templates
|
||||
combodo.current_environment: '%env(string:COMBODO_CURRENT_ENVIRONMENT)%'
|
||||
combodo.absolute_url: '%env(string:COMBODO_ABSOLUTE_URL)%'
|
||||
combodo.modules.absolute_url: '%env(string:COMBODO_MODULES_ABSOLUTE_URL)%'
|
||||
combodo.modules.absolute_path: !php/const MODULESROOT
|
||||
combodo.portal.base.absolute_url: '%env(string:COMBODO_PORTAL_BASE_ABSOLUTE_URL)%'
|
||||
combodo.portal.base.absolute_path: '%env(string:COMBODO_PORTAL_BASE_ABSOLUTE_PATH)%'
|
||||
combodo.portal.instance.absolute_url: '%env(string:COMBODO_PORTAL_INSTANCE_ABSOLUTE_URL)%'
|
||||
combodo.portal.instance.id: '%env(string:PORTAL_ID)%'
|
||||
|
||||
services:
|
||||
# Default configuration for services in *this* file
|
||||
_defaults:
|
||||
autowire: true # Automatically injects dependencies in your services.
|
||||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
||||
public: false # Allows optimizing the container by removing unused services; this also means
|
||||
# fetching services directly from the container via $container->get() won't work.
|
||||
# The best practice is to be explicit about your dependencies anyway.
|
||||
bind:
|
||||
$bDebug: '%kernel.debug%'
|
||||
$sPortalCachePath: '%kernel.cache_dir%/'
|
||||
$sPortalId: '%env(string:PORTAL_ID)%'
|
||||
$aCombodoPortalInstanceConf: '%combodo.portal.instance.conf%'
|
||||
$sCombodoPortalInstanceAbsoluteUrl: '%env(string:COMBODO_PORTAL_INSTANCE_ABSOLUTE_URL)%'
|
||||
# Default configuration for services in *this* file
|
||||
_defaults:
|
||||
autowire: true # Automatically injects dependencies in your services.
|
||||
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
|
||||
public: false # Allows optimizing the container by removing unused services; this also means
|
||||
# fetching services directly from the container via $container->get() won't work.
|
||||
# The best practice is to be explicit about your dependencies anyway.
|
||||
bind:
|
||||
$bDebug: '%kernel.debug%'
|
||||
$sPortalCachePath: '%kernel.cache_dir%/'
|
||||
$sPortalId: '%env(string:PORTAL_ID)%'
|
||||
$aCombodoPortalInstanceConf: '%combodo.portal.instance.conf%'
|
||||
$sCombodoPortalInstanceAbsoluteUrl: '%env(string:COMBODO_PORTAL_INSTANCE_ABSOLUTE_URL)%'
|
||||
|
||||
# Makes classes in src/ available to be used as services
|
||||
# This creates a service per class whose id is the fully-qualified class name
|
||||
Combodo\iTop\Portal\:
|
||||
resource: '../src/*'
|
||||
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
|
||||
# Makes classes in src/ available to be used as services
|
||||
# This creates a service per class whose id is the fully-qualified class name
|
||||
Combodo\iTop\Portal\:
|
||||
resource: '../src/*'
|
||||
exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
|
||||
|
||||
# Controllers are imported separately to make sure services can be injected
|
||||
# as action arguments even if you don't extend any base controller class
|
||||
Combodo\iTop\Portal\Controller\:
|
||||
resource: '../src/Controller'
|
||||
tags: ['controller.service_arguments']
|
||||
# Controllers are imported separately to make sure services can be injected
|
||||
# as action arguments even if you don't extend any base controller class
|
||||
Combodo\iTop\Portal\Controller\:
|
||||
resource: '../src/Controller'
|
||||
tags: ['controller.service_arguments']
|
||||
|
||||
# Tag services without defining them (see https://symfony.com/doc/current/service_container/tags.html#autoconfiguring-tags)
|
||||
_instanceof:
|
||||
Combodo\iTop\Portal\EventListener\UserProvider:
|
||||
tags: [{ name: 'kernel.event_listener', event: 'kernel.request' }]
|
||||
calls:
|
||||
- [setContainer, ['@service_container']]
|
||||
Combodo\iTop\Portal\EventListener\ApplicationContextSetUrlMakerClass:
|
||||
tags: [{ name: 'kernel.event_listener', event: 'kernel.request' }]
|
||||
# Tag services without defining them (see https://symfony.com/doc/current/service_container/tags.html#autoconfiguring-tags)
|
||||
_instanceof:
|
||||
Combodo\iTop\Portal\EventListener\UserProvider:
|
||||
tags: [{ name: 'kernel.event_listener', event: 'kernel.request' }]
|
||||
calls:
|
||||
- [setContainer, ['@service_container']]
|
||||
Combodo\iTop\Portal\EventListener\ApplicationContextSetUrlMakerClass:
|
||||
tags: [{ name: 'kernel.event_listener', event: 'kernel.request' }]
|
||||
|
||||
# Add more service definitions when explicit configuration is needed
|
||||
# Please note that last definitions always *replace* previous ones
|
||||
# Add more service definitions when explicit configuration is needed
|
||||
# Please note that last definitions always *replace* previous ones
|
||||
|
||||
# Legacy code as a service: since it is not in the auto-wiring path, it needs to be explicitly declared
|
||||
ModuleDesign:
|
||||
public: true
|
||||
class: ModuleDesign
|
||||
arguments:
|
||||
- '%combodo.portal.instance.id%'
|
||||
# Legacy code as a service: since it is not in the auto-wiring path, it needs to be explicitly declared
|
||||
ModuleDesign:
|
||||
public: true
|
||||
class: ModuleDesign
|
||||
arguments:
|
||||
- '%combodo.portal.instance.id%'
|
||||
|
||||
# Decoration
|
||||
# - Compatibility layer with Silex\Application which was used almost everywhere in the portal's templates
|
||||
Combodo\iTop\Portal\Twig\AppVariable:
|
||||
decorates: twig.app_variable
|
||||
arguments:
|
||||
- '@Combodo\iTop\Portal\Twig\AppVariable.inner'
|
||||
- '@service_container'
|
||||
# Decoration
|
||||
# - Compatibility layer with Silex\Application which was used almost everywhere in the portal's templates
|
||||
Combodo\iTop\Portal\Twig\AppVariable:
|
||||
decorates: twig.app_variable
|
||||
arguments:
|
||||
- '@Combodo\iTop\Portal\Twig\AppVariable.inner'
|
||||
- '@service_container'
|
||||
|
||||
# Standard services
|
||||
combodo.current_contact.photo_url:
|
||||
public: true
|
||||
class: Combodo\iTop\Portal\VariableAccessor\CombodoCurrentContactPhotoUrl
|
||||
arguments: ['@combodo.current_user']
|
||||
# Note: This service is initialized with a UserLocal object as it needs a class that can be instantiated.
|
||||
# Anyway, it will be replaced with the real class by UserProvider in onKernelRequestEvent.
|
||||
# Note: Services relying on this one should use \User in their signature and not \UserLocal.
|
||||
combodo.current_user:
|
||||
public: true
|
||||
class: UserLocal
|
||||
# Standard services
|
||||
combodo.current_contact.photo_url:
|
||||
public: true
|
||||
class: Combodo\iTop\Portal\VariableAccessor\CombodoCurrentContactPhotoUrl
|
||||
arguments: ['@combodo.current_user']
|
||||
# Note: This service is initialized with a UserLocal object as it needs a class that can be instantiated.
|
||||
# Anyway, it will be replaced with the real class by UserProvider in onKernelRequestEvent.
|
||||
# Note: Services relying on this one should use \User in their signature and not \UserLocal.
|
||||
combodo.current_user:
|
||||
public: true
|
||||
class: UserLocal
|
||||
|
||||
# Aliases
|
||||
brick_collection:
|
||||
alias: Combodo\iTop\Portal\Brick\BrickCollection
|
||||
public: true
|
||||
request_manipulator:
|
||||
alias: Combodo\iTop\Portal\Helper\RequestManipulatorHelper
|
||||
public: true
|
||||
scope_validator:
|
||||
alias: Combodo\iTop\Portal\Helper\ScopeValidatorHelper
|
||||
public: true
|
||||
security_helper:
|
||||
alias: Combodo\iTop\Portal\Helper\SecurityHelper
|
||||
public: true
|
||||
context_manipulator:
|
||||
alias: Combodo\iTop\Portal\Helper\ContextManipulatorHelper
|
||||
public: true
|
||||
lifecycle_validator:
|
||||
alias: Combodo\iTop\Portal\Helper\LifecycleValidatorHelper
|
||||
public: true
|
||||
url_generator:
|
||||
alias: router
|
||||
public: true
|
||||
object_form_handler:
|
||||
alias: Combodo\iTop\Portal\Helper\ObjectFormHandlerHelper
|
||||
public: true
|
||||
browse_brick:
|
||||
alias: Combodo\iTop\Portal\Helper\BrowseBrickHelper
|
||||
public: true
|
||||
# Aliases
|
||||
brick_collection:
|
||||
alias: Combodo\iTop\Portal\Brick\BrickCollection
|
||||
public: true
|
||||
request_manipulator:
|
||||
alias: Combodo\iTop\Portal\Helper\RequestManipulatorHelper
|
||||
public: true
|
||||
scope_validator:
|
||||
alias: Combodo\iTop\Portal\Helper\ScopeValidatorHelper
|
||||
public: true
|
||||
security_helper:
|
||||
alias: Combodo\iTop\Portal\Helper\SecurityHelper
|
||||
public: true
|
||||
context_manipulator:
|
||||
alias: Combodo\iTop\Portal\Helper\ContextManipulatorHelper
|
||||
public: true
|
||||
lifecycle_validator:
|
||||
alias: Combodo\iTop\Portal\Helper\LifecycleValidatorHelper
|
||||
public: true
|
||||
url_generator:
|
||||
alias: router
|
||||
public: true
|
||||
object_form_handler:
|
||||
alias: Combodo\iTop\Portal\Helper\ObjectFormHandlerHelper
|
||||
public: true
|
||||
browse_brick:
|
||||
alias: Combodo\iTop\Portal\Helper\BrowseBrickHelper
|
||||
public: true
|
||||
Reference in New Issue
Block a user