[FEATURE] Backport Object Type Converter from Flow
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Reflection / ReflectionService.php
index 998eb31..f302e35 100644 (file)
@@ -152,7 +152,7 @@ class ReflectionService implements \TYPO3\CMS\Core\SingletonInterface {
        /**
         * @var array
         */
-       protected $methodReflections;
+       protected $methodReflections = array();
 
        /**
         * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
@@ -247,6 +247,27 @@ class ReflectionService implements \TYPO3\CMS\Core\SingletonInterface {
                }
        }
 
+       /**
+        * Wrapper for method_exists() which tells if the given method exists.
+        *
+        * @param string $className Name of the class containing the method
+        * @param string $methodName Name of the method
+        * @return boolean
+        * @api
+        */
+       public function hasMethod($className, $methodName) {
+               try {
+                       if (!array_key_exists($className, $this->methodReflections) || !array_key_exists($methodName, $this->methodReflections[$className])) {
+                               $this->methodReflections[$className][$methodName] = new \TYPO3\CMS\Extbase\Reflection\MethodReflection($className, $methodName);
+                               $this->dataCacheNeedsUpdate = TRUE;
+                       }
+               } catch (\ReflectionException $e) {
+                       // Method does not exist. Store this information in cache.
+                       $this->methodReflections[$className][$methodName] = NULL;
+               }
+               return isset($this->methodReflections[$className][$methodName]);
+       }
+
        /**
         * Returns all tags and their values the specified method is tagged with
         *