[TYPO3-mvc] How to get to typoscipt ?
Franz Koch
typo3.RemoveForMessage at elements-net.de
Thu Jan 13 14:10:56 CET 2011
Hey Tim,
> Interesting, I'll have to look into this some more. One question that comes to my mind is how is it thought to be done in a static utility class?
> Atm I'm using it to access typoscript properties in a simple way by calling Tx_Gstbase_Utility_Div::getSetting( 'some.typo.script.path' ) which will return only the desired part of the settings section. How would the incjection happen?
I can't tell how it is intended/supposed to be done for static classes -
I can only tell how I do it currently. I use a initialize method which
is taking care of this and is called by other static methods depending
on that stuff. So in your case your 'getSetting' method would have to
call the initialize action then. It could probably look something like this:
private static function initialize() {
if (self::$isInitialized == FALSE) {
self::$objectManager =
t3lib_div::makeInstance('Tx_Extbase_Object_Manager');
$configurationManager =
self::$objectManager->get('Tx_Extbase_Configuration_ConfigurationManagerInterface
');
self::$settings =
$configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS,
'ExtKeyInUpperCamelCase', 'PluginKeyInUpperCamelCase');
self::$isInitilized = TRUE;
}
}
public static function getSettings($path) {
self::initialize();
return ...
}
Another possibility would be to make it a singleton and instantiate it
wherever you need it using the objectManager - then the DI is working of
course.
--
kind regards,
Franz Koch
More information about the TYPO3-project-typo3v4mvc
mailing list