TYPO3 CMS  TYPO3_7-6
ExtensionRepository.php
Go to the documentation of this file.
1 <?php
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 
18 
23 {
27  protected $objectManager;
28 
32  protected $listUtility;
33 
37  protected $extensions = [];
38 
42  public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
43  {
44  $this->objectManager = $objectManager;
45  }
46 
50  public function injectListUtility(\TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility)
51  {
52  $this->listUtility = $listUtility;
53  }
54 
60  public function findAll()
61  {
62  if (empty($this->extensions)) {
63  $extensions = $this->listUtility->getAvailableAndInstalledExtensionsWithAdditionalInformation();
64  foreach ($extensions as $entry) {
65  if (empty($entry['installed']) || $entry['installed'] !== true) {
66  continue;
67  }
69  $extension = $this->objectManager->get(
70  \TYPO3\CMS\Lang\Domain\Model\Extension::class,
71  $entry['key'],
72  $entry['title'],
73  $this->getExtensionIconWithPath($entry)
74  );
75  $extension->setVersionFromString($entry['version']);
76  if ($entry['ext_icon_width'] > 0) {
77  $extension->setIconWidth($entry['ext_icon_width']);
78  }
79  if ($entry['ext_icon_height'] > 0) {
80  $extension->setIconHeight($entry['ext_icon_height']);
81  }
82 
83  $this->extensions[$entry['key']] = $extension;
84  }
85  ksort($this->extensions);
86  }
87  return $this->extensions;
88  }
89 
95  public function countAll()
96  {
97  $extensions = $this->findAll();
98  return count($extensions);
99  }
100 
107  public function findOneByOffset($offset)
108  {
109  $extensions = $this->findAll();
110  $extensions = array_values($extensions);
111  $offset = (int)$offset;
112  if (!empty($extensions[$offset])) {
113  return $extensions[$offset];
114  }
115  return null;
116  }
117 
124  protected function getExtensionIconWithPath($extensionEntry)
125  {
126  $extensionIcon = $GLOBALS['TYPO3_LOADED_EXT'][$extensionEntry['key']]['ext_icon'];
127  if (empty($extensionIcon)) {
128  $extensionIcon = ExtensionManagementUtility::getExtensionIcon(PATH_site . $extensionEntry['siteRelPath'] . '/');
129  }
130  if (empty($extensionIcon)) {
131  $extensionIcon = ExtensionManagementUtility::siteRelPath('core') . 'ext_icon.png';
132  } else {
133  $extensionIcon = '../' . $extensionEntry['siteRelPath'] . '/' . $extensionIcon;
134  }
135  return $extensionIcon;
136  }
137 }
injectListUtility(\TYPO3\CMS\Extensionmanager\Utility\ListUtility $listUtility)
injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']
static getExtensionIcon($extensionPath, $returnFullPath=false)