/** * Default implementation for use in compiled templates * * @param array $arguments * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext * @return mixed */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { if (self::$staticReflectionService === NULL) { $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); self::$staticReflectionService = $objectManager->get('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService'); } $property = $arguments['property']; $validatorName = isset($arguments['validatorName']) ? $arguments['validatorName'] : NULL; $object = isset($arguments['object']) ? $arguments['object'] : NULL; if (NULL === $object) { $object = self::getFormObject($renderingContext->getViewHelperVariableContainer()); } $className = get_class($object); if (FALSE !== strpos($property, '.')) { $pathSegments = explode('.', $property); foreach ($pathSegments as $property) { if (TRUE === ctype_digit($property)) { continue; } $annotations = self::$staticReflectionService->getPropertyTagValues($className, $property, 'var'); $possibleClassName = array_pop($annotations); if (FALSE !== strpos($possibleClassName, '<')) { $className = array_pop(explode('<', trim($possibleClassName, '>'))); } elseif (TRUE === class_exists($possibleClassName)) { $className = $possibleClassName; } } } $annotations = self::$staticReflectionService->getPropertyTagValues($className, $property, 'validate'); $hasEvaluated = TRUE; if (0 < count($annotations) && (NULL === $validatorName || TRUE === in_array($validatorName, $annotations))) { return static::renderStaticThenChild($arguments, $hasEvaluated); } return static::renderStaticElseChild($arguments, $hasEvaluated); }
/** * @param array $arguments * @return boolean */ protected static function evaluateCondition($arguments = null) { if (self::$staticReflectionService === null) { $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); self::$staticReflectionService = $objectManager->get('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService'); } $property = $arguments['property']; $validatorName = isset($arguments['validatorName']) ? $arguments['validatorName'] : null; $object = isset($arguments['object']) ? $arguments['object'] : null; if (null === $object) { $object = static::getFormObject($renderingContext->getViewHelperVariableContainer()); } $className = get_class($object); if (false !== strpos($property, '.')) { $pathSegments = explode('.', $property); foreach ($pathSegments as $property) { if (true === ctype_digit($property)) { continue; } $annotations = self::$staticReflectionService->getPropertyTagValues($className, $property, 'var'); $possibleClassName = array_pop($annotations); if (false !== strpos($possibleClassName, '<')) { $className = array_pop(explode('<', trim($possibleClassName, '>'))); } elseif (true === class_exists($possibleClassName)) { $className = $possibleClassName; } } } $annotations = self::$staticReflectionService->getPropertyTagValues($className, $property, 'validate'); return count($annotations) && (!$validatorName || in_array($validatorName, $annotations)); }