Code

Updated property handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 21 May 2010 09:26:49 +0000 (09:26 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 21 May 2010 09:26:49 +0000 (09:26 +0000)
-Request plInfo for plugin classes only once.

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18611 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_configRegistry.inc

index a196a2ab69f227c77ea734348fd7a9d01d87a785..5051d21b6221dc7412529932a38da648d2aabb29 100644 (file)
@@ -13,9 +13,30 @@ class configRegistry{
     // Excludes property values defined in ldap 
     public $ignoreLdapProperties = FALSE;
 
+    // Contains all classes with plInfo
+    public $classesWithInfo = array();
+
     function __construct($config)
     {
         $this->config = &$config;
+
+        // Detect classes that have a plInfo method 
+        global $class_mapping;
+        foreach ($class_mapping as $cname => $path){
+            $cmethods = get_class_methods($cname);
+            if (is_array($cmethods) && in_array_ics('plInfo',$cmethods)){
+
+                // Get plugin definitions
+                $def = call_user_func(array($cname, 'plInfo'));;
+
+                // Register Post Events (postmodfiy,postcreate,postremove,checkhook)
+                if(count($def)){
+                    $this->classesWithInfo[$cname] = $def;
+                }
+            }
+        }
+
+        // (Re)Load properties
         $this->reload();
     }
 
@@ -102,36 +123,29 @@ class configRegistry{
             $this->status = 'finished';
         }
 
-        global $class_mapping;
-        foreach ($class_mapping as $cname => $path){
-            $cmethods = get_class_methods($cname);
-            if (is_array($cmethods) && in_array_ics('plInfo',$cmethods)){
-
-                // Get plugin definitions
-                $def = call_user_func(array($cname, 'plInfo'));;
-
-                // Register Post Events (postmodfiy,postcreate,postremove,checkhook)
-                if(count($def)){
-                    
-                    $name = $cname;
-                    $name = (isset($def['plShortName'])) ? $def['plShortName'] : $cname;
-                    $name = (isset($def['plDescription'])) ? $def['plDescription'] : $cname;
-
-                    $this->classToName[$cname] = $name;
-                    $data = array('name' => 'postcreate','type' => 'command');
-                    $this->register($cname, $data);    
-                    $data = array('name' => 'postremove','type' => 'command');
-                    $this->register($cname, $data);    
-                    $data = array('name' => 'postmodify','type' => 'command');
-                    $this->register($cname, $data);    
-                    $data = array('name' => 'check', 'type' => 'command');
-                    $this->register($cname, $data);    
-                }
-
-                if(isset($def['plProperties'])){
-                    foreach($def['plProperties'] as $property){
-                        $this->register($cname, $property);
-                    }
+        // Register plugin properties.
+        foreach ($this->classesWithInfo as $cname => $def){
+
+            // Detect class name
+            $name = $cname;
+            $name = (isset($def['plShortName'])) ? $def['plShortName'] : $cname;
+            $name = (isset($def['plDescription'])) ? $def['plDescription'] : $cname;
+
+            // Register post events
+            $this->classToName[$cname] = $name;
+            $data = array('name' => 'postcreate','type' => 'command');
+            $this->register($cname, $data);    
+            $data = array('name' => 'postremove','type' => 'command');
+            $this->register($cname, $data);    
+            $data = array('name' => 'postmodify','type' => 'command');
+            $this->register($cname, $data);    
+            $data = array('name' => 'check', 'type' => 'command');
+            $this->register($cname, $data);    
+
+            // Register properties 
+            if(isset($def['plProperties'])){
+                foreach($def['plProperties'] as $property){
+                    $this->register($cname, $property);
                 }
             }
         }