Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Some utility functions for working with extensions.
- *
- * @author Daniel Siepmann <[email protected]>
- */
- class Tx_YourHelpers_Utility_ExtensionUtility extends Tx_Extbase_Utility_Extension {
- /**
- * Get the extension name from the given class.
- *
- * Takes loaded extension in account. If the extension is not loaded
- * it will not return the name.
- *
- * @param string $classname The classname you want the extension name from.
- * @return boolean The extension name or an empty string if
- * extension name could not get or the extension is not loaded.
- *
- * @author Daniel Siepmann <[email protected]>
- */
- public function getExtensionNameFromClassname( $classname ) {
- $extKey = '';
- $extensionName = '';
- list( , $extensionName ) = explode( '_', $classname );
- if (empty( $extensionName )) {
- return '';
- }
- $extKey = t3lib_div::camelCaseToLowerCaseUnderscored( $extensionName );
- if (t3lib_extMgm::isLoaded( $extKey ) === true) {
- return $extensionName;
- }
- return '';
- }
- /**
- * Get the extension key from the given class.
- *
- * @param string $classname The classname you want the extension key from.
- * @return string The extension key or an empty string if
- * extension name could not get or the extension is not loaded.
- *
- * @author Daniel Siepmann <[email protected]>
- */
- public function getExtensionKeyFromClassname( $classname ) {
- $extensionName = $this->getExtensionNameFromClassname( $classname );
- if (empty( $extensionName )) {
- return $extensionName;
- }
- return t3lib_div::camelCaseToLowerCaseUnderscored( $extensionName );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment