TYPO3 CMS  TYPO3_7-6
DocbookGeneratorService.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is part of the TYPO3 project - inspiring people to share! *
6  * *
7  * TYPO3 is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU General Public License version 2 as published by *
9  * the Free Software Foundation. *
10  * *
11  * This script is distributed in the hope that it will be useful, but *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
14  * Public License for more details. *
15  * */
16 
30 {
35  protected $objectManager;
36 
42  public function userFunc()
43  {
44  $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
45  $this->injectDocCommentParser($this->objectManager->get(\TYPO3\CMS\Extbase\Reflection\DocCommentParser::class));
46  $this->injectReflectionService($this->objectManager->get(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class));
47  return $this->generateDocbook(\TYPO3\CMS\Fluid\ViewHelpers::class);
48  }
49 
56  protected function getClassNamesInNamespace($namespace)
57  {
58  $namespaceParts = explode('\\', $namespace);
59  if ($namespaceParts[count($namespaceParts) - 1] == '') {
60  }
61  $classFilePathAndName = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(\TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($namespaceParts[2])) . 'Classes/';
62  $classFilePathAndName .= implode(array_slice($namespaceParts, 3, -1), '/') . '/';
63  $classNames = [];
64  $this->recursiveClassNameSearch($namespace, $classFilePathAndName, $classNames);
65  sort($classNames);
66  return $classNames;
67  }
68 
77  private function recursiveClassNameSearch($namespace, $directory, &$classNames)
78  {
79  $dh = opendir($directory);
80  $counter = 0;
81  while (($file = readdir($dh)) !== false) {
82  if ($file == '.' || $file == '..' || $file == '.svn') {
83  continue;
84  }
85  if (is_file($directory . $file)) {
86  if (substr($file, 0, 8) == 'Abstract') {
87  continue;
88  }
89  $classNames[] = $namespace . substr($file, 0, -4);
90  } elseif (is_dir($directory . $file)) {
91  $this->recursiveClassNameSearch($namespace . $file . '\\', $directory . $file . '/', $classNames);
92  }
93  }
94  closedir($dh);
95  }
96 }
recursiveClassNameSearch($namespace, $directory, &$classNames)