Optimized reflection service to reflect only the methods needed
authorChristopher Hlubek <hlubek@networkteam.com>
Fri, 27 Mar 2009 16:13:57 +0000 (16:13 +0000)
committerChristopher Hlubek <hlubek@networkteam.com>
Fri, 27 Mar 2009 16:13:57 +0000 (16:13 +0000)
typo3/sysext/extbase/Classes/Reflection/Service.php

index 3b57a4a..7fe8bb3 100644 (file)
@@ -61,13 +61,10 @@ class Tx_ExtBase_Reflection_Service implements t3lib_Singleton {
        public function getMethodTagsValues($className, $methodName) {
                if (!isset($this->methodTagsValues[$className][$methodName])) {
                        $this->methodTagsValues[$className][$methodName] = array();
-                       $class = $this->getClassReflection($className);
-                       foreach ($class->getMethods() as $method) {
-                               $classMethodName = $method->getName();
-                               foreach ($method->getTagsValues() as $tag => $values) {
-                                       if (array_search($tag, $this->ignoredTags) === FALSE) {
-                                               $this->methodTagsValues[$className][$classMethodName][$tag] = $values;
-                                       }
+                       $method = $this->getMethodReflection($className, $methodName);
+                       foreach ($method->getTagsValues() as $tag => $values) {
+                               if (array_search($tag, $this->ignoredTags) === FALSE) {
+                                       $this->methodTagsValues[$className][$methodName][$tag] = $values;
                                }
                        }
                }
@@ -87,7 +84,7 @@ class Tx_ExtBase_Reflection_Service implements t3lib_Singleton {
         */
        public function getMethodParameters($className, $methodName) {
                if (!isset($this->methodParameters[$className][$methodName])) {
-                       $method = new ReflectionMethod($className, $methodName);
+                       $method = $this->getMethodReflection($className, $methodName);
                        $this->methodParameters[$className][$methodName] = array();
                        foreach($method->getParameters() as $parameter) {
                                $this->methodParameters[$className][$methodName][$parameter->getName()] = $this->convertParameterReflectionToArray($parameter, $method);
@@ -141,5 +138,12 @@ class Tx_ExtBase_Reflection_Service implements t3lib_Singleton {
                }
                return $this->classReflections[$className];
        }
+
+       protected function getMethodReflection($className, $methodName) {
+               if (!isset($this->methodReflections[$className][$methodName])) {
+                       $this->methodReflections[$className][$methodName] = new Tx_ExtBase_Reflection_MethodReflection($className, $methodName);
+               }
+               return $this->methodReflections[$className][$methodName];
+       }
 }
 ?>
\ No newline at end of file