TYPO3 CMS  TYPO3_6-2
AbstractGenerator.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
17 abstract class AbstractGenerator {
18 
25 
32  protected $docCommentParser;
33 
38  protected $reflectionService;
39 
44  public function __construct() {
45  \TYPO3\CMS\Fluid\Fluid::$debugMode = TRUE; // We want ViewHelper argument documentation
46  $this->abstractViewHelperReflectionClass = new \TYPO3\CMS\Extbase\Reflection\ClassReflection('TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper');
47  }
48 
55  protected function getClassNamesInNamespace($namespace) {
56  $affectedViewHelperClassNames = array();
57 
58  $allViewHelperClassNames = $this->reflectionService->getAllSubClassNamesForClass('TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper');
59  foreach ($allViewHelperClassNames as $viewHelperClassName) {
60  if ($this->reflectionService->isClassAbstract($viewHelperClassName)) {
61  continue;
62  }
63  if (strncmp($namespace, $viewHelperClassName, strlen($namespace)) === 0) {
64  $affectedViewHelperClassNames[] = $viewHelperClassName;
65  }
66  }
67  sort($affectedViewHelperClassNames);
68  return $affectedViewHelperClassNames;
69  }
70 
80  protected function getTagNameForClass($className, $namespace) {
82  $strippedClassName = substr($className, strlen($namespace), -10);
83  $classNameParts = explode(\TYPO3\CMS\Fluid\Fluid::NAMESPACE_SEPARATOR, $strippedClassName);
84  return implode(
85  '.',
86  array_map(
87  function($element) {
88  return lcfirst($element);
89  },
90  $classNameParts
91  )
92  );
93  }
94 
103  protected function addChildWithCData(\SimpleXMLElement $parentXmlNode, $childNodeName, $childNodeValue) {
104  // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
105  $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
106  $parentDomNode = dom_import_simplexml($parentXmlNode);
107  $domDocument = new \DOMDocument();
108 
109  $childNode = $domDocument->appendChild($domDocument->createElement($childNodeName));
110  $childNode->appendChild($domDocument->createCDATASection($childNodeValue));
111  $childNodeTarget = $parentDomNode->ownerDocument->importNode($childNode, true);
112  $parentDomNode->appendChild($childNodeTarget);
113  $returnValue = simplexml_import_dom($childNodeTarget);
114  libxml_disable_entity_loader($previousValueOfEntityLoader);
115 
116  return $returnValue;
117  }
118 
119 }
addChildWithCData(\SimpleXMLElement $parentXmlNode, $childNodeName, $childNodeValue)
const NAMESPACE_SEPARATOR
Definition: Fluid.php:19