mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
Internal: MetaModel to ignore classes declared only with the purpose of implementing behaviors (missing function Init). Note: declaring such a class as abstract is recommended, though it seems enough to omit the Init method. Perfs: benchmarked as an additional 1ms out of 1s for the whole page.
SVN:trunk[2262]
This commit is contained in:
@@ -1348,7 +1348,8 @@ abstract class MetaModel
|
||||
|
||||
// Initialize the classes (declared attributes, etc.)
|
||||
//
|
||||
foreach(get_declared_classes() as $sPHPClass) {
|
||||
foreach(get_declared_classes() as $sPHPClass)
|
||||
{
|
||||
if (is_subclass_of($sPHPClass, 'DBObject'))
|
||||
{
|
||||
$sParent = get_parent_class($sPHPClass);
|
||||
@@ -1357,14 +1358,22 @@ abstract class MetaModel
|
||||
// Inherit info about attributes to ignore
|
||||
self::$m_aIgnoredAttributes[$sPHPClass] = self::$m_aIgnoredAttributes[$sParent];
|
||||
}
|
||||
if (method_exists($sPHPClass, 'Init'))
|
||||
try
|
||||
{
|
||||
call_user_func(array($sPHPClass, 'Init'));
|
||||
foreach (MetaModel::EnumPlugins('iOnClassInitialization') as $sPluginClass => $oClassInit)
|
||||
$oMethod = new ReflectionMethod($sPHPClass, 'Init');
|
||||
if ($oMethod->getDeclaringClass()->name == $sPHPClass)
|
||||
{
|
||||
$oClassInit->OnAfterClassInitialization($sPHPClass);
|
||||
call_user_func(array($sPHPClass, 'Init'));
|
||||
foreach (MetaModel::EnumPlugins('iOnClassInitialization') as $sPluginClass => $oClassInit)
|
||||
{
|
||||
$oClassInit->OnAfterClassInitialization($sPHPClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (ReflectionException $e)
|
||||
{
|
||||
// This class is only implementing methods, ignore it from the MetaModel perspective
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1991,7 +2000,8 @@ abstract class MetaModel
|
||||
{
|
||||
self::_check_subclass($sClass);
|
||||
$aSubClasses = array();
|
||||
foreach(get_declared_classes() as $sSubClass) {
|
||||
foreach(self::$m_aClassParams as $sSubClass => $foo)
|
||||
{
|
||||
if (is_subclass_of($sSubClass, $sClass))
|
||||
{
|
||||
$aSubClasses[] = $sSubClass;
|
||||
|
||||
Reference in New Issue
Block a user