[TASK] Use fully qualified name resolution in PHP 5.5
[Packages/TYPO3.CMS.git] / typo3 / sysext / lang / Classes / Domain / Repository / ExtensionRepository.php
1 <?php
2 namespace TYPO3\CMS\Lang\Domain\Repository;
3 /**
4 * This file is part of the TYPO3 CMS project.
5 *
6 * It is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License, either version 2
8 * of the License, or any later version.
9 *
10 * For the full copyright and license information, please read the
11 * LICENSE.txt file that was distributed with this source code.
12 *
13 * The TYPO3 project - inspiring people to share!
14 */
15
16 /**
17 * Extension repository
18 *
19 * @author Sebastian Fischer <typo3@evoweb.de>
20 */
21 class ExtensionRepository {
22 /**
23 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
24 */
25 protected $objectManager;
26
27 /**
28 * @var \TYPO3\CMS\Extensionmanager\Utility\ListUtility
29 */
30 protected $listUtility;
31
32 /**
33 * @var array
34 */
35 protected $extensions = array();
36
37 /**
38 * Injects the object manager
39 *
40 * @param \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager
41 * @return void
42 */
43 public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $objectManager) {
44 $this->objectManager = $objectManager;
45 }
46
47 /**
48 * Inject the list utility
49 *
50 * @param \TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility
51 * @return void
52 */
53 public function injectListUtility(\TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility) {
54 $this->listUtility = $listUtility;
55 }
56
57 /**
58 * Returns all objects of this repository.
59 *
60 * @return array
61 */
62 public function findAll() {
63 if (!count($this->extensions)) {
64 $availableAndInstalledExtensions = $this->listUtility->getAvailableAndInstalledExtensionsWithAdditionalInformation();
65
66 foreach ($availableAndInstalledExtensions as $entry) {
67 /** @var $extension \TYPO3\CMS\Lang\Domain\Model\Extension */
68 $extension = $this->objectManager->get(
69 \TYPO3\CMS\Lang\Domain\Model\Extension::class,
70 $entry['key'],
71 $entry['title'],
72 $this->getExtensionIconWithPath($entry)
73 );
74 $extension->setVersionFromString($entry['version']);
75 $this->extensions[$entry['key']] = $extension;
76 }
77
78 // Sort the list by extension key
79 ksort($this->extensions);
80 }
81
82 return $this->extensions;
83 }
84
85 /**
86 * @param array $extensionEntry
87 * @return string
88 */
89 protected function getExtensionIconWithPath($extensionEntry) {
90 $extensionIcon = $GLOBALS['TYPO3_LOADED_EXT'][$extensionEntry['key']]['ext_icon'];
91 if (empty($extensionIcon)) {
92 $extensionIcon = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getExtensionIcon(PATH_site . $extensionEntry['siteRelPath'] . '/');
93 }
94
95 if (empty($extensionIcon)) {
96 $extensionIcon = '/typo3/clear.gif';
97 } else {
98 $extensionIcon = '../' . $extensionEntry['siteRelPath'] . '/' . $extensionIcon;
99 }
100
101 return $extensionIcon;
102 }
103 }