mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
✅ Move EventService init to Metamodel::Startup() for unit tests
This commit is contained in:
@@ -15,10 +15,7 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||||
use Combodo\iTop\Application\EventRegister\ApplicationEvents;
|
|
||||||
use Combodo\iTop\Application\Helper\Session;
|
use Combodo\iTop\Application\Helper\Session;
|
||||||
use Combodo\iTop\Service\Events\EventData;
|
|
||||||
use Combodo\iTop\Service\Events\EventService;
|
|
||||||
|
|
||||||
require_once(APPROOT.'core/cmdbobject.class.inc.php');
|
require_once(APPROOT.'core/cmdbobject.class.inc.php');
|
||||||
require_once(APPROOT.'application/utils.inc.php');
|
require_once(APPROOT.'application/utils.inc.php');
|
||||||
@@ -103,6 +100,3 @@ else
|
|||||||
}
|
}
|
||||||
$sConfigFile = APPCONF.$sEnv.'/'.ITOP_CONFIG_FILE;
|
$sConfigFile = APPCONF.$sEnv.'/'.ITOP_CONFIG_FILE;
|
||||||
MetaModel::Startup($sConfigFile, false /* $bModelOnly */, $bAllowCache, false /* $bTraceSourceFiles */, $sEnv);
|
MetaModel::Startup($sConfigFile, false /* $bModelOnly */, $bAllowCache, false /* $bTraceSourceFiles */, $sEnv);
|
||||||
// Event service must be initialized after the MetaModel startup, otherwise it cannot discover classes implementing the iEventServiceSetup interface
|
|
||||||
EventService::InitService();
|
|
||||||
EventService::FireEvent(new EventData(ApplicationEvents::APPLICATION_EVENT_METAMODEL_STARTED));
|
|
||||||
|
|||||||
@@ -17,7 +17,10 @@
|
|||||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||||
//
|
//
|
||||||
|
|
||||||
|
use Combodo\iTop\Application\EventRegister\ApplicationEvents;
|
||||||
use Combodo\iTop\Core\MetaModel\FriendlyNameType;
|
use Combodo\iTop\Core\MetaModel\FriendlyNameType;
|
||||||
|
use Combodo\iTop\Service\Events\EventData;
|
||||||
|
use Combodo\iTop\Service\Events\EventService;
|
||||||
|
|
||||||
require_once APPROOT.'core/modulehandler.class.inc.php';
|
require_once APPROOT.'core/modulehandler.class.inc.php';
|
||||||
require_once APPROOT.'core/querymodifier.class.inc.php';
|
require_once APPROOT.'core/querymodifier.class.inc.php';
|
||||||
@@ -6343,36 +6346,37 @@ abstract class MetaModel
|
|||||||
{
|
{
|
||||||
self::$m_sEnvironment = $sEnvironment;
|
self::$m_sEnvironment = $sEnvironment;
|
||||||
|
|
||||||
if (!defined('MODULESROOT'))
|
try {
|
||||||
{
|
if (!defined('MODULESROOT')) {
|
||||||
define('MODULESROOT', APPROOT.'env-'.self::$m_sEnvironment.'/');
|
define('MODULESROOT', APPROOT.'env-'.self::$m_sEnvironment.'/');
|
||||||
|
|
||||||
self::$m_bTraceSourceFiles = $bTraceSourceFiles;
|
self::$m_bTraceSourceFiles = $bTraceSourceFiles;
|
||||||
|
|
||||||
// $config can be either a filename, or a Configuration object (volatile!)
|
// $config can be either a filename, or a Configuration object (volatile!)
|
||||||
if ($config instanceof Config)
|
if ($config instanceof Config) {
|
||||||
{
|
self::LoadConfig($config, $bAllowCache);
|
||||||
self::LoadConfig($config, $bAllowCache);
|
} else {
|
||||||
}
|
self::LoadConfig(new Config($config), $bAllowCache);
|
||||||
else
|
}
|
||||||
{
|
|
||||||
self::LoadConfig(new Config($config), $bAllowCache);
|
if ($bModelOnly) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($bModelOnly)
|
CMDBSource::SelectDB(self::$m_sDBName);
|
||||||
{
|
|
||||||
return;
|
foreach (MetaModel::EnumPlugins('ModuleHandlerApiInterface') as $oPHPClass) {
|
||||||
|
$oPHPClass::OnMetaModelStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ExpressionCache::Warmup();
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
// Event service must be initialized after the MetaModel startup, otherwise it cannot discover classes implementing the iEventServiceSetup interface
|
||||||
|
EventService::InitService();
|
||||||
|
EventService::FireEvent(new EventData(ApplicationEvents::APPLICATION_EVENT_METAMODEL_STARTED));
|
||||||
}
|
}
|
||||||
|
|
||||||
CMDBSource::SelectDB(self::$m_sDBName);
|
|
||||||
|
|
||||||
foreach(MetaModel::EnumPlugins('ModuleHandlerApiInterface') as $oPHPClass)
|
|
||||||
{
|
|
||||||
$oPHPClass::OnMetaModelStarted();
|
|
||||||
}
|
|
||||||
|
|
||||||
ExpressionCache::Warmup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user