TYPO3 CMS  TYPO3_6-2
LoadedExtensionArrayElement.php
Go to the documentation of this file.
1 <?php
21 class LoadedExtensionArrayElement implements \IteratorAggregate, \ArrayAccess, \Serializable, \Countable {
22 
26  protected $package;
27 
31  protected $extensionFilesToCheckFor = array(
32  'ext_localconf.php',
33  'ext_tables.php',
34  'ext_tables.sql',
35  'ext_tables_static+adt.sql',
36  'ext_typoscript_constants.txt',
37  'ext_typoscript_setup.txt'
38  );
39 
43  protected $extensionInformation = array();
44 
50  public function __construct(\TYPO3\Flow\Package\PackageInterface $package) {
51  $this->package = $package;
53  $this->initializeExtensionFiles();
54  $this->initializeExtensionIcon();
55  }
56 
62  protected function initializeBasicExtensionInformation() {
63  $pathSite = PATH_site;
64  $pathSiteLength = strlen($pathSite);
65  $absolutePackagePath = $this->package->getPackagePath();
66  if (substr($absolutePackagePath, 0, $pathSiteLength) === $pathSite) {
67  $relativePackagePathToPathSite = substr($absolutePackagePath, $pathSiteLength);
68  $relativePackagePathToPathSiteSegments = explode('/', $relativePackagePathToPathSite);
69  $relativePackagePathToPathTypo3 = NULL;
70  $packageType = NULL;
71  // Determine if extension is installed locally, globally or system (in this order)
72  switch (implode('/', array_slice($relativePackagePathToPathSiteSegments, 0, 2))) {
73  case 'typo3conf/Packages':
74  $packageType = 'C';
75  $relativePackagePathToPathTypo3 = '../typo3conf/Packages/' . implode('/', array_slice($relativePackagePathToPathSiteSegments, 2));
76  break;
77  case 'typo3conf/ext':
78  $packageType = 'L';
79  $relativePackagePathToPathTypo3 = '../typo3conf/ext/' . implode('/', array_slice($relativePackagePathToPathSiteSegments, 2));
80  break;
81  case TYPO3_mainDir . 'ext':
82  $packageType = 'G';
83  $relativePackagePathToPathTypo3 = 'ext/' . implode('/', array_slice($relativePackagePathToPathSiteSegments, 2));
84  break;
85  case TYPO3_mainDir . 'sysext':
86  $packageType = 'S';
87  $relativePackagePathToPathTypo3 = 'sysext/' . implode('/', array_slice($relativePackagePathToPathSiteSegments, 2));
88  break;
89  case 'typo3temp/test_ext':
90  $packageType = 'T';
91  $relativePackagePathToPathTypo3 = '../typo3temp/test_ext/' . implode('/', array_slice($relativePackagePathToPathSiteSegments, 2));
92  break;
93  }
94  if ($packageType !== NULL && $relativePackagePathToPathSite !== NULL && $relativePackagePathToPathTypo3 !== NULL) {
95  $this->extensionInformation['type'] = $packageType;
96  $this->extensionInformation['siteRelPath'] = $relativePackagePathToPathSite;
97  $this->extensionInformation['typo3RelPath'] = $relativePackagePathToPathTypo3;
98  }
99  }
100  }
101 
107  protected function initializeExtensionIcon() {
108  $this->extensionInformation['ext_icon'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getExtensionIcon($this->package->getPackagePath());
109  }
110 
116  protected function initializeExtensionFiles() {
117  foreach ($this->extensionFilesToCheckFor as $fileName) {
118  $absolutePathToFile = $this->package->getPackagePath() . $fileName;
119  if (@file_exists($absolutePathToFile)) {
120  $this->extensionInformation[$fileName] = $absolutePathToFile;
121  }
122  }
123  }
124 
131  public function getIterator() {
132  return new \ArrayIterator($this->extensionInformation);
133  }
134 
142  public function offsetExists($offset) {
143  return isset($this->extensionInformation[$offset]);
144  }
145 
153  public function offsetGet($offset) {
154  return $this->extensionInformation[$offset];
155  }
156 
166  public function offsetSet($offset, $value) {
167  throw new \InvalidArgumentException('The array $GLOBALS[\'TYPO3_LOADED_EXT\'] may not be modified.', 1361915115);
168  }
169 
178  public function offsetUnset($offset) {
179  throw new \InvalidArgumentException('The array $GLOBALS[\'TYPO3_LOADED_EXT\'] may not be modified.', 1361915206);
180  }
181 
188  public function serialize() {
189  return serialize($this->extensionInformation);
190  }
191 
199  public function unserialize($serialized) {
200  $this->extensionInformation = unserialize($serialized);
201  }
202 
209  public function count() {
210  return count($this->extensionInformation);
211  }
212 
216  public function toArray() {
217  return iterator_to_array($this);
218  }
219 }
static getExtensionIcon($extensionPath, $returnFullPath=FALSE)
__construct(\TYPO3\Flow\Package\PackageInterface $package)