[TASK] Add more fixers for php-cs-fixer
[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 use TYPO3\CMS\Core\Imaging\Icon;
18 use TYPO3\CMS\Core\Imaging\IconFactory;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Documentation\ViewHelpers\FormatsViewHelper;
21 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
22
23 /**
24 * This slot listens to a signal in Extension Manager to add links to
25 * manuals available locally.
26 */
27 class ExtensionManager
28 {
29 /**
30 * @var \TYPO3\CMS\Documentation\Domain\Model\Document[]
31 */
32 protected static $documents = null;
33
34 /**
35 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
36 */
37 protected $objectManager;
38
39 /**
40 * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
41 */
42 public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
43 {
44 $this->objectManager = $objectManager;
45 }
46
47 /**
48 * Processes the list of actions for a given extension and adds
49 * a link to the manual(s), if available.
50 *
51 * @param array $extension
52 * @param array $actions
53 * @return void
54 */
55 public function processActions(array $extension, array &$actions)
56 {
57 if (static::$documents === null) {
58 /** @var \TYPO3\CMS\Documentation\Controller\DocumentController $documentController */
59 $documentController = $this->objectManager->get(\TYPO3\CMS\Documentation\Controller\DocumentController::class);
60 static::$documents = $documentController->getDocuments();
61 }
62
63 $extensionKey = $extension['key'];
64 $documentKey = 'typo3cms.extensions.' . $extensionKey;
65
66 if (isset(static::$documents[$documentKey])) {
67 $document = static::$documents[$documentKey];
68
69 foreach ($document->getTranslations() as $documentTranslation) {
70 $actions[] = FormatsViewHelper::renderStatic(
71 [
72 'documentTranslation' => $documentTranslation,
73 ],
74 function () {
75 },
76 new RenderingContext()
77 );
78 }
79 } else {
80 $iconFactory = GeneralUtility::makeInstance(IconFactory::class);
81 $emptyIcon = $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render();
82 $actions[] = '<span class="btn btn-default disabled">' . $emptyIcon . '</span>';
83 $actions[] = '<span class="btn btn-default disabled">' . $emptyIcon . '</span>';
84 $actions[] = '<span class="btn btn-default disabled">' . $emptyIcon . '</span>';
85 }
86 }
87 }