TYPO3 CMS  TYPO3_7-6
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  {
53  $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
54  $this->initializeConfiguration($configuration);
55  $this->configureObjectManager();
56  $ajaxWidgetContextHolder = $this->objectManager->get(\TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder::class);
57  $widgetIdentifier = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('fluid-widget-id');
58  $widgetContext = $ajaxWidgetContextHolder->get($widgetIdentifier);
59  $configuration['extensionName'] = $widgetContext->getParentExtensionName();
60  $configuration['pluginName'] = $widgetContext->getParentPluginName();
61  $extbaseBootstrap = $this->objectManager->get(\TYPO3\CMS\Extbase\Core\Bootstrap::class);
62  $extbaseBootstrap->cObj = $this->cObj;
63  return $extbaseBootstrap->run($content, $configuration);
64  }
65 
73  public function initializeConfiguration($configuration)
74  {
75  $this->configurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
77  $contentObject = isset($this->cObj) ? $this->cObj : \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
78  $this->configurationManager->setContentObject($contentObject);
79  $this->configurationManager->setConfiguration($configuration);
80  }
81 
90  public function configureObjectManager()
91  {
92  $typoScriptSetup = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
93  if (!is_array($typoScriptSetup['config.']['tx_extbase.']['objects.'])) {
94  return;
95  }
96  $objectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class);
97  foreach ($typoScriptSetup['config.']['tx_extbase.']['objects.'] as $classNameWithDot => $classConfiguration) {
98  if (isset($classConfiguration['className'])) {
99  $originalClassName = rtrim($classNameWithDot, '.');
100  $objectContainer->registerImplementation($originalClassName, $classConfiguration['className']);
101  }
102  }
103  }
104 }
run($content, $configuration)
Definition: Bootstrap.php:51