[TASK] Re-work/simplify copyright header in PHP files - Part 2
[Packages/TYPO3.CMS.git] / typo3 / sysext / documentation / Classes / Slots / ExtensionManager.php
1 <?php
2 namespace TYPO3\CMS\Documentation\Slots;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * This slot listens to a signal in Extension Manager to add links to
19 * manuals available locally.
20 */
21 class ExtensionManager {
22
23 /**
24 * @var \TYPO3\CMS\Documentation\Domain\Model\Document[]
25 */
26 static protected $documents = NULL;
27
28 /**
29 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
30 * @inject
31 */
32 protected $objectManager;
33
34 /**
35 * Processes the list of actions for a given extension and adds
36 * a link to the manual(s), if available.
37 *
38 * @param array $extension
39 * @param array $actions
40 * @return void
41 */
42 public function processActions(array $extension, array &$actions) {
43 if (static::$documents === NULL) {
44 /** @var \TYPO3\CMS\Documentation\Controller\DocumentController $documentController */
45 $documentController = $this->objectManager->get('TYPO3\\CMS\\Documentation\\Controller\\DocumentController');
46 static::$documents = $documentController->getDocuments();
47 }
48
49 $extensionKey = $extension['key'];
50 $documentKey = 'typo3cms.extensions.' . $extensionKey;
51
52 if (isset(static::$documents[$documentKey])) {
53 $document = static::$documents[$documentKey];
54
55 /** @var \TYPO3\CMS\Documentation\ViewHelpers\FormatsViewHelper $formatsViewHelper */
56 $formatsViewHelper = $this->objectManager->get('TYPO3\\CMS\\Documentation\\ViewHelpers\\FormatsViewHelper');
57
58 foreach ($document->getTranslations() as $documentTranslation) {
59 $actions[] = $formatsViewHelper->render($documentTranslation);
60 }
61 }
62 }
63
64 }