/**
  * @param ClassReflection $reflection
  * @param string $propertyName
  * @param string $annotationName
  * @return array
  */
 protected static function getPropertyAnnotations(ClassReflection $reflection, $propertyName, $annotationName)
 {
     $reflectedProperty = $reflection->getProperty($propertyName);
     if (TRUE === $reflectedProperty->isTaggedWith($annotationName)) {
         return $reflectedProperty->getTagValues($annotationName);
     }
     return NULL;
 }
 /**
  * Generate the XML Schema for a given class name.
  *
  * @param string $className Class name to generate the schema for.
  * @param string $viewHelperNamespace Namespace prefix. Used to split off the first parts of the class name.
  * @param \SimpleXMLElement $xmlRootNode XML root node where the xsd:element is appended.
  * @return void
  */
 protected function generateXmlForClassName($className, $viewHelperNamespace, \SimpleXMLElement $xmlRootNode)
 {
     $reflectionClass = new ClassReflection($className);
     if (!$reflectionClass->isSubclassOf($this->abstractViewHelperReflectionClass)) {
         return;
     }
     $tagName = $this->getTagNameForClass($className, $viewHelperNamespace);
     $xsdElement = $xmlRootNode->addChild('xsd:element');
     $xsdElement['name'] = $tagName;
     $this->docCommentParser->parseDocComment($reflectionClass->getDocComment());
     $this->addDocumentation($this->docCommentParser->getDescription(), $xsdElement);
     $xsdComplexType = $xsdElement->addChild('xsd:complexType');
     $xsdComplexType['mixed'] = 'true';
     $xsdSequence = $xsdComplexType->addChild('xsd:sequence');
     $xsdAny = $xsdSequence->addChild('xsd:any');
     $xsdAny['minOccurs'] = '0';
     $xsdAny['maxOccurs'] = 'unbounded';
     $this->addAttributes($className, $xsdComplexType);
 }
 /**
  * compares the number of properties found by parsing
  * with those retrieved from the reflection class
  *
  * @param \EBT\ExtensionBuilder\Domain\Model\ClassObject\ClassObject $classObject
  * @param \TYPO3\CMS\Extbase\Reflection\ClassReflection $classReflection
  * @return void
  */
 public function ParserFindsAllProperties($classObject, $classReflection)
 {
     $reflectionPropertyCount = count($classReflection->getProperties());
     $classObjectPropertCount = count($classObject->getProperties());
     $this->assertEquals($classObjectPropertCount, $reflectionPropertyCount, 'Not all Properties were found!');
 }
Exemple #4
0
 /**
  * Reflects the given class and stores the results in this service's properties.
  *
  * @param string $className Full qualified name of the class to reflect
  * @return void
  */
 protected function reflectClass($className)
 {
     $class = new ClassReflection($className);
     $this->reflectedClassNames[$className] = time();
     foreach ($class->getTagsValues() as $tag => $values) {
         if (array_search($tag, $this->ignoredTags) === false) {
             $this->taggedClasses[$tag][] = $className;
             $this->classTagsValues[$className][$tag] = $values;
         }
     }
     foreach ($class->getProperties() as $property) {
         $propertyName = $property->getName();
         $this->classPropertyNames[$className][] = $propertyName;
         foreach ($property->getTagsValues() as $tag => $values) {
             if (array_search($tag, $this->ignoredTags) === false) {
                 $this->propertyTagsValues[$className][$propertyName][$tag] = $values;
             }
         }
     }
     foreach ($class->getMethods() as $method) {
         $methodName = $method->getName();
         foreach ($method->getTagsValues() as $tag => $values) {
             if (array_search($tag, $this->ignoredTags) === false) {
                 $this->methodTagsValues[$className][$methodName][$tag] = $values;
             }
         }
         foreach ($method->getParameters() as $parameterPosition => $parameter) {
             $this->methodParameters[$className][$methodName][$parameter->getName()] = $this->convertParameterReflectionToArray($parameter, $parameterPosition, $method);
         }
     }
     ksort($this->reflectedClassNames);
     $this->dataCacheNeedsUpdate = true;
 }
 /**
  * @param string $extensionKey
  * @param string $p1
  * @param string $p2
  * @param string $p3
  * @param string $p4
  * @param string $p5
  * @return string
  * @return void
  */
 public function indexAction($extensionKey = NULL, $p1 = NULL, $p2 = NULL, $p3 = NULL, $p4 = NULL, $p5 = NULL)
 {
     if (!$extensionKey && !$p1 && !$p2 && !$p3 && !$p4 && !$p5) {
         list($extensionKey, $p1, $p2, $p3, $p4, $p5) = array_pad((array) $this->getBackendUserAuthentication()->getModuleData('tools_schema_arguments'), 6, NULL);
     } else {
         $this->getBackendUserAuthentication()->pushModuleData('tools_schema_arguments', array($extensionKey, $p1, $p2, $p3, $p4, $p5));
     }
     if (NULL === $extensionKey) {
         $extensionKey = 'TYPO3.Fluid';
     }
     list($vendor, $legacyExtensionKey) = $this->schemaService->getRealExtensionKeyAndVendorFromCombinedExtensionKey($extensionKey);
     $version = ExtensionManagementUtility::getExtensionVersion($extensionKey);
     $namespaceName = str_replace('_', '', $legacyExtensionKey);
     $namespaceName = strtolower($namespaceName);
     $namespaceAlias = str_replace('_', '', $extensionKey);
     if (isset($this->extensionKeyToNamespaceMap[$legacyExtensionKey])) {
         $namespaceAlias = $this->extensionKeyToNamespaceMap[$legacyExtensionKey];
     }
     $segments = array($p1, $p2, $p3, $p4, $p5);
     $segments = $this->trimPathSegments($segments);
     $arguments = $this->segmentsToArguments($extensionKey, $segments);
     $extensionName = GeneralUtility::underscoredToUpperCamelCase($legacyExtensionKey);
     $extensionKeys = $this->detectExtensionsContainingViewHelpers();
     $displayHeadsUp = FALSE;
     if (isset($this->extensionKeyToNamespaceMap[$namespaceName])) {
         $namespaceName = $this->extensionKeyToNamespaceMap[$namespaceName];
     }
     $tree = $this->buildTreeFromClassPath(ExtensionManagementUtility::extPath($legacyExtensionKey, 'Classes/ViewHelpers/'));
     $viewHelperArguments = array();
     $node = NULL;
     $docComment = '';
     $className = implode('/', $segments);
     if (TRUE === ExtensionManagementUtility::isLoaded($legacyExtensionKey)) {
         $extensionPath = ExtensionManagementUtility::extPath($legacyExtensionKey);
         if (!empty($className)) {
             $className = $vendor . '\\' . $extensionName . '\\ViewHelpers\\' . str_replace('/', '\\', $className);
             $viewHelperArguments = $this->objectManager->get($className)->prepareArguments();
             $reflection = new ClassReflection($className);
             $docComment = $reflection->getDocComment();
             $this->docCommentParser->parseDocComment($docComment);
             $docComment = $this->docCommentParser->getDescription();
             $docComment = trim($docComment, "/ \n");
         } else {
             $readmeFile = $extensionPath . 'Classes/ViewHelpers/README.md';
             if (TRUE === file_exists($readmeFile)) {
                 $readmeFile = file_get_contents($readmeFile);
             } else {
                 unset($readmeFile);
             }
         }
     }
     $variables = array('view' => 'Index', 'action' => 'index', 'readmeFile' => $readmeFile, 'history' => $history, 'name' => end($segments), 'schemaFile' => $relativeSchemaFile, 'keys' => array(), 'namespaceUrl' => $targetNamespaceUrl, 'displayHeadsUp' => $displayHeadsUp, 'namespaceName' => $namespaceName, 'namespaceAlias' => $namespaceAlias, 'className' => $className, 'ns' => $namespaceName, 'isFile' => class_exists($className), 'arguments' => $arguments, 'segments' => $segments, 'markdownBlacklisted' => in_array($extensionKey, $this->markdownBlacklistedExtensionKeys), 'viewHelperArguments' => $viewHelperArguments, 'docComment' => $docComment, 'tree' => $tree, 'version' => $version, 'extensionKey' => $extensionKey, 'extensionKeys' => $extensionKeys, 'extensionName' => $extensionName);
     $this->view->assignMultiple($variables);
 }
 /**
  * Get the tag configuration from this method and respect multiple line and space configuration
  *
  * @param MethodReflection|ClassReflection $reflectionObject
  * @param array                            $tagNames
  *
  * @return array
  */
 public static function getTagConfiguration($reflectionObject, array $tagNames)
 {
     $tags = $reflectionObject->getTagsValues();
     $configuration = [];
     foreach ($tagNames as $tagName) {
         $configuration[$tagName] = [];
         if (!is_array($tags[$tagName])) {
             continue;
         }
         foreach ($tags[$tagName] as $c) {
             $configuration[$tagName] = array_merge($configuration[$tagName], GeneralUtility::trimExplode(' ', $c, true));
         }
     }
     return $configuration;
 }