TYPO3 CMS  TYPO3_8-7
Bootstrap.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
20 class Bootstrap
21 {
28  public $cObj;
29 
33  protected $objectManager;
34 
39 
45  public function run($content, $configuration)
46  {
47  $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
48  $this->initializeConfiguration($configuration);
49  $this->configureObjectManager();
50  $ajaxWidgetContextHolder = $this->objectManager->get(\TYPO3\CMS\Fluid\Core\Widget\AjaxWidgetContextHolder::class);
51  $widgetIdentifier = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('fluid-widget-id');
52  $widgetContext = $ajaxWidgetContextHolder->get($widgetIdentifier);
53  $configuration['vendorName'] = $widgetContext->getParentVendorName();
54  $configuration['extensionName'] = $widgetContext->getParentExtensionName();
55  $configuration['pluginName'] = $widgetContext->getParentPluginName();
56  $extbaseBootstrap = $this->objectManager->get(\TYPO3\CMS\Extbase\Core\Bootstrap::class);
57  $extbaseBootstrap->cObj = $this->cObj;
58  return $extbaseBootstrap->run($content, $configuration);
59  }
60 
67  public function initializeConfiguration($configuration)
68  {
69  $this->configurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
71  $contentObject = isset($this->cObj) ? $this->cObj : \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
72  $this->configurationManager->setContentObject($contentObject);
73  $this->configurationManager->setConfiguration($configuration);
74  }
75 
83  public function configureObjectManager()
84  {
85  $typoScriptSetup = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
86  if (!is_array($typoScriptSetup['config.']['tx_extbase.']['objects.'])) {
87  return;
88  }
89  $objectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class);
90  foreach ($typoScriptSetup['config.']['tx_extbase.']['objects.'] as $classNameWithDot => $classConfiguration) {
91  if (isset($classConfiguration['className'])) {
92  $originalClassName = rtrim($classNameWithDot, '.');
93  $objectContainer->registerImplementation($originalClassName, $classConfiguration['className']);
94  }
95  }
96  }
97 }
run($content, $configuration)
Definition: Bootstrap.php:45
static makeInstance($className,... $constructorArguments)