2015-06-15 13 views

Odpowiedz

3

Powyższa metoda działa tylko w kontrolerze lub klasie usług, poniżej której będzie działała w dowolnych plikach PHP w rozszerzeniu.

$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\Extbase\\Object\\ObjectManager'); 
$configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); 
$extbaseFrameworkConfiguration = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); 
$storagePid = $extbaseFrameworkConfiguration['plugin.']['tx_guesthouse_guesthouse.']['settings.']['storagePid']; 
6

Możesz dodać poniżej linii w kontrolerze.

$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');  
$configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); 
$setting = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS); 
$ts_config = $setting['plugin.']['tx_xxxx.']['settings.']['storagePid']; 

Myślę, że będzie ci pomocna. Możesz także użyć tych ustawień litero3 w plikach usług.

+3

Myślę, że to zbyt skomplikowane. W kontekście typu extbase możesz pozwolić architektowi na bezpośrednie wstrzykiwanie menedżera ConfigurationManager. Następnie możesz użyć '$ settings = $ configManager-> getConfiguration (\ TYPO3 \ CMS \ Extbase \ Configuration \ ConfigurationManagerInterface :: CONFIGURATION_TYPE_SETTINGS);', nie potrzebujesz pełnego TS. – Jost

+0

@Jost Tak, poprawiłem odpowiedź. –

3

Tylko dla TYPO3 Backend

Dla wielu domenach korzenia przed uzyskaniem konfiguracji

$configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager'); 
$configurationManager->currentPageId = ROOT_PID_OF_YOUR_DOMAIN; 
$extbaseFrameworkConfiguration = $configurationManager->getTypoScriptSetup(); 

//Following will be resultant array, find your required stuff from it 
print_r($extbaseFrameworkConfiguration); 

Uwaga: Nie zapomnij, aby rozszerzyć swoją klasę z \TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager w aby uzyskać dostęp bo to chroniony zmienne

-3
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');  
$configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); 
$setting = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS); 
$ts_config = $setting['plugin.']['tx_xxxx.']['settings.']['storagePid']; 
+0

Dobra odpowiedź zawsze będzie zawierała wyjaśnienie tego, co zostało zrobione i dlaczego została wykonana w taki sposób, nie tylko dla PO, ale dla przyszłych odwiedzających SO. Dodaj opis, aby inni zrozumieli. :) –

+0

kopia odpowiedzi Vishal Tanna –

0

Teraz, w Typo3 8.x, currentPageId jest zabezpieczony tak, nie możemy ustawić go bezpośrednio, a nie byłoby każda metoda zestaw zdefiniowane w klasie bazowej. Poniżej znajduje się poprawny kod w nowej wersji, która może ci pomóc. Dzięki za właściwy kierunek.

$configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager'); 
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($configurationManager); 
$configurationManager->getDefaultBackendStoragePid(); 
$extbaseFrameworkConfiguration = $configurationManager->getTypoScriptSetup(); 

//Following will be resultant array, find your required stuff from it 
\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($extbaseFrameworkConfiguration); 
Powiązane problemy