‪TYPO3CMS  9.5
LoadedExtensionArrayElement.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 
19 
25 class ‪LoadedExtensionArrayElement implements \IteratorAggregate, \ArrayAccess, \Serializable, \Countable
26 {
30  protected ‪$package;
31 
35  protected ‪$extensionFilesToCheckFor = [
36  'ext_localconf.php',
37  'ext_tables.php',
38  'ext_tables.sql',
39  'ext_tables_static+adt.sql',
40  'ext_typoscript_constants.typoscript',
41  'ext_typoscript_setup.typoscript',
42  'ext_typoscript_constants.txt',
43  'ext_typoscript_setup.txt'
44  ];
45 
49  protected ‪$extensionInformation = [];
50 
57  {
58  $this->package = $package;
62  }
63 
67  protected function ‪initializeBasicExtensionInformation()
68  {
69  $pathSite = ‪Environment::getPublicPath() . '/';
70  $pathSiteLength = strlen($pathSite);
71  $absolutePackagePath = $this->package->getPackagePath();
72  if (strpos($absolutePackagePath, $pathSite) === 0) {
73  $relativePackagePathToPathSite = substr($absolutePackagePath, $pathSiteLength);
74  $relativePackagePathToPathSiteSegments = explode('/', $relativePackagePathToPathSite);
75  $packageType = null;
76  // Determine if extension is installed locally, globally or system (in this order)
77  switch (implode('/', array_slice($relativePackagePathToPathSiteSegments, 0, 2))) {
78  case 'typo3conf/ext':
79  $packageType = 'L';
80  break;
81  case TYPO3_mainDir . 'ext':
82  $packageType = 'G';
83  break;
84  case TYPO3_mainDir . 'sysext':
85  $packageType = 'S';
86  break;
87  case 'typo3temp/var/tests/test_ext':
88  $packageType = 'T';
89  break;
90  }
91  if ($packageType !== null) {
92  $this->extensionInformation['type'] = $packageType;
93  }
94  }
95  }
96 
100  protected function ‪initializeExtensionIcon()
101  {
102  $this->extensionInformation['ext_icon'] = ‪\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getExtensionIcon($this->package->getPackagePath());
103  }
104 
108  protected function ‪initializeExtensionFiles()
109  {
110  foreach ($this->extensionFilesToCheckFor as $fileName) {
111  $absolutePathToFile = $this->package->getPackagePath() . $fileName;
112  if (@file_exists($absolutePathToFile)) {
113  $this->extensionInformation[$fileName] = $absolutePathToFile;
114  }
115  }
116  }
117 
124  public function ‪getIterator()
125  {
126  return new \ArrayIterator($this->extensionInformation);
127  }
128 
136  public function ‪offsetExists($offset)
137  {
138  return isset($this->extensionInformation[$offset]);
139  }
140 
148  public function ‪offsetGet($offset)
149  {
150  return $this->extensionInformation[$offset];
151  }
152 
161  public function ‪offsetSet($offset, $value)
162  {
163  throw new \InvalidArgumentException('The array $GLOBALS[\'TYPO3_LOADED_EXT\'] may not be modified.', 1361915115);
164  }
165 
173  public function ‪offsetUnset($offset)
174  {
175  throw new \InvalidArgumentException('The array $GLOBALS[\'TYPO3_LOADED_EXT\'] may not be modified.', 1361915206);
176  }
177 
184  public function ‪serialize()
185  {
186  return ‪serialize($this->extensionInformation);
187  }
188 
196  public function ‪unserialize($serialized)
197  {
198  $this->extensionInformation = ‪unserialize($serialized);
199  }
200 
207  public function ‪count()
208  {
209  return ‪count($this->extensionInformation);
210  }
211 
215  public function ‪toArray()
216  {
217  return iterator_to_array($this);
218  }
219 }
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\offsetSet
‪offsetSet($offset, $value)
Definition: LoadedExtensionArrayElement.php:158
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:153
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement
Definition: LoadedExtensionArrayElement.php:26
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\unserialize
‪mixed unserialize($serialized)
Definition: LoadedExtensionArrayElement.php:193
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\$extensionFilesToCheckFor
‪array $extensionFilesToCheckFor
Definition: LoadedExtensionArrayElement.php:33
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\__construct
‪__construct(PackageInterface $package)
Definition: LoadedExtensionArrayElement.php:53
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\getIterator
‪Traversable getIterator()
Definition: LoadedExtensionArrayElement.php:121
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\initializeExtensionIcon
‪initializeExtensionIcon()
Definition: LoadedExtensionArrayElement.php:97
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\$extensionInformation
‪array $extensionInformation
Definition: LoadedExtensionArrayElement.php:46
‪TYPO3\CMS\Core\Package\PackageInterface
Definition: PackageInterface.php:21
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\initializeBasicExtensionInformation
‪initializeBasicExtensionInformation()
Definition: LoadedExtensionArrayElement.php:64
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\toArray
‪array toArray()
Definition: LoadedExtensionArrayElement.php:212
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\offsetGet
‪mixed offsetGet($offset)
Definition: LoadedExtensionArrayElement.php:145
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\count
‪int count()
Definition: LoadedExtensionArrayElement.php:204
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\$package
‪PackageInterface $package
Definition: LoadedExtensionArrayElement.php:29
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\serialize
‪string serialize()
Definition: LoadedExtensionArrayElement.php:181
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\offsetExists
‪bool offsetExists($offset)
Definition: LoadedExtensionArrayElement.php:133
‪TYPO3\CMS\Core\Utility\ExtensionManagementUtility\getExtensionIcon
‪static string getExtensionIcon($extensionPath, $returnFullPath=false)
Definition: ExtensionManagementUtility.php:1511
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\offsetUnset
‪offsetUnset($offset)
Definition: LoadedExtensionArrayElement.php:170
‪TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement\initializeExtensionFiles
‪initializeExtensionFiles()
Definition: LoadedExtensionArrayElement.php:105
‪TYPO3\CMS\Core\Compatibility
Definition: LoadedExtensionArrayElement.php:2