[TYPO3-dev] how to iterate over LoadedExtensionArrayElement

Franz Holzinger franz at ttproducts.de
Mon Nov 4 14:40:00 CET 2013


Hello,

since TYPO3 6.2 the TYPO3_LOADED_EXT envirnoment variable gives an 
object of the class TYPO3\CMS\Core\Compatibility\LoadedExtensionsArray.
If I iterate over its elements in a foreach:

foreach ($loadedExt as $k => $v) {
..
}

then I get element objects of the class 
TYPO3\CMS\Core\Compatibility\LoadedExtensionArrayElement.

But how must the PHP code iterate over this element in order to retrieve 
the information if an extension key is installed or not? When I debug 
the object, then it is very big. I do not find the solution.


In TYPO3 4.x this code could discover if an extension $rawKey has been 
installed.

----------------
class tx_div2007 {

...

/**
  * Check if the given extension key is within the loaded extensions
  *
  * The key can be given in the regular format or with underscores stripped.
  *
  * @param	string		extension key to check
  * @return	boolean		is the key valid?
  */
public function getValidKey ($rawKey) {

$loadedExt = self::getGlobal('TYPO3_LOADED_EXT');
$uKeys = array_keys($loadedExt);
foreach((array)$uKeys as $uKey) {
	if( str_replace('_', '', $uKey) == str_replace('_', '', $rawKey) ){
		$result =  $uKey;
	}
}

return $result ? $result : FALSE;


}
...

}
--------------
This does not work any more under TYPO3 6.x.


How must I change this code for TYPO3 6.x in order to use the iterator 
LoadedExtensionArrayElement?

./typo3/sysext/core/Classes/Compatibility/LoadedExtensionArrayElement.php


- Franz




More information about the TYPO3-dev mailing list