/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $hooks = []; $folder = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Hooks/'; $files = FileUtility::getBaseFilesInDir($folder, 'php'); foreach ($files as $hookFile) { $hookClass = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Hooks/' . $hookFile); if (!$loader->isInstantiableClass($hookClass)) { continue; } $classReflection = ReflectionUtility::createReflectionClass($hookClass); // add class hook $tagConfiguration = ReflectionUtility::getTagConfiguration($classReflection, ['hook']); if (sizeof($tagConfiguration['hook'])) { $hooks[] = ['locations' => $tagConfiguration['hook'], 'configuration' => $hookClass]; } // add method hooks foreach ($classReflection->getMethods(MethodReflection::IS_PUBLIC) as $methodReflection) { /** @var $methodReflection \TYPO3\CMS\Extbase\Reflection\MethodReflection */ $tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['hook']); if (sizeof($tagConfiguration['hook'])) { $hooks[] = ['locations' => $tagConfiguration['hook'], 'configuration' => $hookClass . '->' . $methodReflection->getName()]; } } } return $hooks; }
/** * Get the Arguments from the original method via Reflection. * If the $aspectClassName not available (e.g. Extension is not installed) then * throw a Exception. * * @param $aspectClassName * @param $aspectJoinPoint * * @return array * @throws \HDNET\Autoloader\Exception */ protected function getMethodArgumentsFromClassMethod($aspectClassName, $aspectJoinPoint) { $reflectionClass = ReflectionUtility::createReflectionClass($aspectClassName); $methodReflection = $reflectionClass->getMethod($aspectJoinPoint); /** @var $classReflection \TYPO3\CMS\Extbase\Reflection\ClassReflection */ $methodArguments = $methodReflection->getParameters(); $arguments = []; /** @var $argument \ReflectionParameter */ foreach ($methodArguments as $argument) { $arguments[] = ['name' => $argument->getName(), 'typeHint' => $argument->getClass()->name, 'reference' => $argument->isPassedByReference()]; } return $arguments; }
/** * Check if the given class is a smart object * * Also add a work around, because the static_info_tables SPL Autoloader * get into a conflict with different classes. * * @param string $className * * @return bool */ public static function isSmartObjectClass($className) { $riskAutoLoader = ['SJBR\\StaticInfoTables\\Cache\\CachedClassLoader', 'autoload']; $registerAutoLoader = spl_autoload_unregister($riskAutoLoader); if (!class_exists($className)) { $return = false; } else { $classReflection = ReflectionUtility::createReflectionClass($className); $return = !(bool) (!$classReflection->isInstantiable() || !$classReflection->isTaggedWith('db')); } if ($registerAutoLoader) { spl_autoload_register($riskAutoLoader, true, true); } return $return; }
/** * Check if the class is tagged with noHeader * * @param $class * * @return bool */ protected function isTaggedWithNoHeader($class) { $classReflection = ReflectionUtility::createReflectionClass($class); return $classReflection->isTaggedWith('noHeader'); }