TYPO3 CMS  TYPO3_6-2
Bootstrap.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * *
12  * This script is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
14  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
15  * General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU Lesser General Public *
18  * License along with the script. *
19  * If not, see http://www.gnu.org/licenses/lgpl.html *
20  * *
21  * The TYPO3 project - inspiring people to share! *
22  * */
26 class Bootstrap {
27 
34  public $cObj;
35 
39  protected $objectManager;
40 
45 
51  public function run($content, $configuration) {
52  $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
53  $this->initializeConfiguration($configuration);
54  $this->configureObjectManager();
55  $ajaxWidgetContextHolder = $this->objectManager->get('TYPO3\\CMS\\Fluid\\Core\\Widget\\AjaxWidgetContextHolder');
56  $widgetIdentifier = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('fluid-widget-id');
57  $widgetContext = $ajaxWidgetContextHolder->get($widgetIdentifier);
58  $configuration['extensionName'] = $widgetContext->getParentExtensionName();
59  $configuration['pluginName'] = $widgetContext->getParentPluginName();
60  $extbaseBootstrap = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Core\\Bootstrap');
61  $extbaseBootstrap->cObj = $this->cObj;
62  return $extbaseBootstrap->run($content, $configuration);
63  }
64 
72  public function initializeConfiguration($configuration) {
73  $this->configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
75  $contentObject = isset($this->cObj) ? $this->cObj : \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
76  $this->configurationManager->setContentObject($contentObject);
77  $this->configurationManager->setConfiguration($configuration);
78  }
79 
88  public function configureObjectManager() {
89  $typoScriptSetup = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
90  if (!is_array($typoScriptSetup['config.']['tx_extbase.']['objects.'])) {
91  return;
92  }
93  $objectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\Container\\Container');
94  foreach ($typoScriptSetup['config.']['tx_extbase.']['objects.'] as $classNameWithDot => $classConfiguration) {
95  if (isset($classConfiguration['className'])) {
96  $originalClassName = rtrim($classNameWithDot, '.');
97  $objectContainer->registerImplementation($originalClassName, $classConfiguration['className']);
98  }
99  }
100  }
101 }
run($content, $configuration)
Definition: Bootstrap.php:51