Feature #13643 » FluidXsdGeneration.patch

Jascha Dachtera, 2011-03-05 17:00

View differences:

Classes/Controller/StandardController.php
79 79
	public function generateXsdAction($baseNamespace, $namespacePrefix) {
80 80
		$xsdFileContents = $this->xsdGenerator->generateXSD($baseNamespace);
81 81

  
82
		$path = 'Resources/Fluid/XSD/';
82
		$path = '_Resources/Fluid/XSD/';
83 83
		if (!is_dir(FLOW3_PATH_WEB . $path)) {
84 84
			\F3\FLOW3\Utility\Files::createDirectoryRecursively(FLOW3_PATH_WEB . $path);
85 85
		}
......
89 89
		$fp = fopen(FLOW3_PATH_WEB . $filename, 'w');
90 90
		fputs($fp, $xsdFileContents);
91 91
		fclose($fp);
92
		
93
		$request = $this->controllerContext->getRequest();
92 94

  
93 95
		return $this->view->assign('xsdPath', $filename)
94 96
		                  ->assign('namespaceUri', 'http://typo3.org/ns/fluid/' . str_replace('\\', '/', $baseNamespace))
95 97
		                  ->assign('namespacePrefix', $namespacePrefix)
96
		                  ->assign('view', $this->view)
98
		                  ->assign('request', $request)
99
		                  
97 100
		                  ->render();
98 101
	}
99 102
}
Classes/Service/AbstractGenerator.php
49 49
	 * @var \F3\FLOW3\Reflection\DocCommentParser
50 50
	 */
51 51
	protected $docCommentParser;
52
	
53
	/**
54
	* The reflection Service
55
	*
56
	* @var \F3\FLOW3\Reflection\ReflectionService
57
	*/
58
	protected $reflectionService;
52 59

  
53 60
	/**
54 61
	 * Constructor. Sets $this->abstractViewHelperReflectionClass
......
72 79
		$this->objectManager = $objectManager;
73 80
	}
74 81

  
82
     /**
83
	 * Inject the reflection service.
84
	 *
85
	 * @param \F3\FLOW3\Reflection\ReflectionService $reflectionService the object manager to inject
86
	 * @return void
87
	 */
88
	public function injectReflectionService(\F3\FLOW3\Reflection\ReflectionService $reflectionService) {
89
		$this->reflectionService = $reflectionService;
90
	}
91

  
75 92
	/**
76
	 * Get all class names inside this namespace and return them as array.
93
	 * Get all non abstract class names inheriting \F3\Fluid\Core\ViewHelper\AbstractViewHelper inside this namespace and return them as array.
77 94
	 *
78 95
	 * @param string $namespace
79
	 * @return array Array of all class names inside a given namespace.
96
	 * @return array Array of all non abstract class names inheriting \F3\Fluid\Core\ViewHelper\AbstractViewHelper inside a given namespace.
80 97
	 * @author Sebastian Kurfürst <sebastian@typo3.org>
81 98
	 */
82 99
	protected function getClassNamesInNamespace($namespace) {
83
		$viewHelperClassNames = array();
100
		$viewHelperClassNamesInNameSpace = array();
84 101

  
85
		$registeredObjectNames = array_keys($this->objectManager->getRegisteredObjects());
86
		foreach ($registeredObjectNames as $registeredObjectName) {
87
			if (strncmp($namespace, $registeredObjectName, strlen($namespace)) === 0) {
88
				$viewHelperClassNames[] = $registeredObjectName;
102
		$allViewHelperClassNames = $this->reflectionService->getAllSubClassNamesForClass('\F3\Fluid\Core\ViewHelper\AbstractViewHelper');
103
                
104
		foreach ($allViewHelperClassNames as $viewHelperClassName) {
105
			if (strncmp($namespace, $viewHelperClassName, strlen($namespace)) === 0 && !$this->reflectionService->isClassAbstract($viewHelperClassName)) {
106
				$viewHelperClassNamesInNameSpace[] = $viewHelperClassName;
89 107
			}
90 108
		}
91
		sort($viewHelperClassNames);
92
		return $viewHelperClassNames;
109
		sort($viewHelperClassNamesInNameSpace);
110
		return $viewHelperClassNamesInNameSpace;
93 111
	}
94 112

  
95 113
	/**
Resources/Private/Templates/Standard/generateXsd.html
33 33
	<h2>Fluid Autocompletion Generation Wizard</h2>
34 34
	<h2>Step 2<span style="color:#919191">/2</span></h2>
35 35
	<p class="content">
36
	The path to the XSD file is: <b><a href="{xsdPath}">{view.request.baseUri}{xsdPath}</a></b>. Please use the following snippet
36
	The path to the XSD file is: <b><a href="{xsdPath}">{request.baseUri}{xsdPath}</a></b>. Please use the following snippet
37 37
	for autocompletion:
38 38
	<pre>
39 39
&lt;?xml version="1.0"?&gt;
......
41 41
	xmlns:xsi="http://typo3.org/ns/html-base"
42 42
	xmlns:{namespacePrefix}="{namespaceUri}"
43 43
	xsi:schemaLocation="http://typo3.org/ns/html-base
44
		{view.request.baseUri}Resources/Packages/Fluid/html-base.xsd
44
		{request.baseUri}Resources/Packages/Fluid/html-base.xsd
45 45
		{namespaceUri}
46
		{view.request.baseUri}{xsdPath}"&gt;
46
		{request.baseUri}{xsdPath}"&gt;
47 47
	&lt;!-- Your content goes here --&gt;
48 48
&lt;/html&gt;
49 49
	</pre>
    (1-1/1)