mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
Lab "performance"
- move some heavy introspection into cached part of MetaModel aka iterate over get_declared_classes() in order to check is_subclass_of($sPHPClass, 'ModuleHandlerAPI') - make use of an interface in order to rely on existing code SVN:trunk[5926]
This commit is contained in:
@@ -84,14 +84,10 @@ class ApplicationMenu
|
||||
{
|
||||
// Build menus from module handlers
|
||||
//
|
||||
foreach(get_declared_classes() as $sPHPClass)
|
||||
{
|
||||
if (is_subclass_of($sPHPClass, 'ModuleHandlerAPI'))
|
||||
{
|
||||
$aCallSpec = array($sPHPClass, 'OnMenuCreation');
|
||||
call_user_func($aCallSpec);
|
||||
}
|
||||
}
|
||||
foreach(MetaModel::EnumPlugins('ModuleHandlerApiInterface') as $oPHPClass)
|
||||
{
|
||||
$oPHPClass::OnMenuCreation();
|
||||
}
|
||||
|
||||
// Build menus from the menus themselves (e.g. the ShortcutContainerMenuNode will do that)
|
||||
//
|
||||
|
||||
@@ -2599,7 +2599,7 @@ abstract class MetaModel
|
||||
|
||||
// Build the list of available extensions
|
||||
//
|
||||
$aInterfaces = array('iApplicationUIExtension', 'iApplicationObjectExtension', 'iQueryModifier', 'iOnClassInitialization', 'iPopupMenuExtension', 'iPageUIExtension', 'iPortalUIExtension');
|
||||
$aInterfaces = array('iApplicationUIExtension', 'iApplicationObjectExtension', 'iQueryModifier', 'iOnClassInitialization', 'iPopupMenuExtension', 'iPageUIExtension', 'iPortalUIExtension', 'ModuleHandlerApiInterface');
|
||||
foreach($aInterfaces as $sInterface)
|
||||
{
|
||||
self::$m_aExtensionClasses[$sInterface] = array();
|
||||
@@ -5858,20 +5858,10 @@ abstract class MetaModel
|
||||
|
||||
CMDBSource::SelectDB(self::$m_sDBName);
|
||||
|
||||
foreach(get_declared_classes() as $sPHPClass)
|
||||
{
|
||||
if (is_subclass_of($sPHPClass, 'ModuleHandlerAPI'))
|
||||
{
|
||||
$aCallSpec = array($sPHPClass, 'OnMetaModelStarted');
|
||||
call_user_func_array($aCallSpec, array());
|
||||
}
|
||||
}
|
||||
|
||||
// if (false)
|
||||
// {
|
||||
// echo "Debug<br/>\n";
|
||||
// self::static_var_dump();
|
||||
// }
|
||||
foreach(MetaModel::EnumPlugins('ModuleHandlerApiInterface') as $oPHPClass)
|
||||
{
|
||||
$oPHPClass::OnMetaModelStarted();
|
||||
}
|
||||
|
||||
ExpressionCache::Warmup();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
abstract class ModuleHandlerAPI
|
||||
abstract class ModuleHandlerAPI implements ModuleHandlerApiInterface
|
||||
{
|
||||
public static function OnMetaModelStarted()
|
||||
{
|
||||
@@ -34,5 +34,19 @@ abstract class ModuleHandlerAPI
|
||||
public static function OnMenuCreation()
|
||||
{
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
interface ModuleHandlerApiInterface
|
||||
{
|
||||
public static function OnMetaModelStarted();
|
||||
|
||||
public static function OnMenuCreation();
|
||||
|
||||
public function __construct(); //empty params is required in order to be instantiable by MetaModel::InitClasses()
|
||||
}
|
||||
Reference in New Issue
Block a user