TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
fluid/Classes/Core/Widget/Bootstrap.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Fluid\Core\Widget;
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['extensionName'] = $widgetContext->getParentExtensionName();
54  $configuration['pluginName'] = $widgetContext->getParentPluginName();
55  $extbaseBootstrap = $this->objectManager->get(\TYPO3\CMS\Extbase\Core\Bootstrap::class);
56  $extbaseBootstrap->cObj = $this->cObj;
57  return $extbaseBootstrap->run($content, $configuration);
58  }
59 
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 
84  public function configureObjectManager()
85  {
86  $typoScriptSetup = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
87  if (!is_array($typoScriptSetup['config.']['tx_extbase.']['objects.'])) {
88  return;
89  }
90  $objectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\Container\Container::class);
91  foreach ($typoScriptSetup['config.']['tx_extbase.']['objects.'] as $classNameWithDot => $classConfiguration) {
92  if (isset($classConfiguration['className'])) {
93  $originalClassName = rtrim($classNameWithDot, '.');
94  $objectContainer->registerImplementation($originalClassName, $classConfiguration['className']);
95  }
96  }
97  }
98 }
static makeInstance($className,...$constructorArguments)