/** * Initializes configuration manager, object container and reflection service * * @param array $configuration * @return void */ protected function initialize(array $configuration) { // initialize unconsumed Request and Response $this->request = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Request'); $this->response = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Response'); // initialize configuration $this->configurationManager->setContentObject(\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer')); $this->configurationManager->setConfiguration($configuration); // configure object container $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); if (isset($frameworkConfiguration['objects'])) { $objectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\Container\\Container'); foreach ($frameworkConfiguration['objects'] as $classNameWithDot => $classConfiguration) { if (isset($classConfiguration['className'])) { $originalClassName = rtrim($classNameWithDot, '.'); $objectContainer->registerImplementation($originalClassName, $classConfiguration['className']); } } } // initialize reflection $reflectionService = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService'); $reflectionService->setDataCache(\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager')->getCache('extbase_reflection')); if (!$reflectionService->isInitialized()) { $reflectionService->initialize(); } }
protected function initializeEnvironment() { /** * @var ConfigurationManager $configurationManager * @var ContentObjectRenderer $contentObjectRenderer */ $this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager'); $this->configurationManager =& $configurationManager; $contentObjectRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $this->configurationManager->setContentObject($contentObjectRenderer); $this->uriBuilder = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Routing\\UriBuilder'); if (empty($GLOBALS['TSFE']->sys_page)) { $GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); } if (empty($GLOBALS['TSFE']->tmpl)) { $GLOBALS['TSFE']->initTemplate(); } if (!isset($GLOBALS['TSFE']->config)) { $GLOBALS['TSFE']->config = array(); } if (empty($GLOBALS['TSFE']->config['config'])) { $GLOBALS['TSFE']->config['config'] = array(); $GLOBALS['TSFE']->config['config']['tx_realurl_enable'] = TRUE; $GLOBALS['TSFE']->config['mainScript'] = 'index.php'; } }
/** * Initializes the Object framework. * * @param array $configuration * @return void * @see initialize() */ public function initializeConfiguration($configuration) { $this->configurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class); /** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject */ $contentObject = isset($this->cObj) ? $this->cObj : \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class); $this->configurationManager->setContentObject($contentObject); $this->configurationManager->setConfiguration($configuration); }
/** * @param ProviderInterface $provider * @param array $row * @param Form $form * @return string|NULL */ protected function renderPreviewSection(ProviderInterface $provider, array $row, Form $form = NULL) { $templatePathAndFilename = $provider->getTemplatePathAndFilename($row); if (NULL === $templatePathAndFilename) { return NULL; } $extensionKey = $provider->getExtensionKey($row); $paths = $provider->getTemplatePaths($row); $flexformVariables = $provider->getFlexFormValues($row); $templateVariables = $provider->getTemplateVariables($row); $variables = RecursiveArrayUtility::merge($templateVariables, $flexformVariables); $variables['row'] = $row; $variables['record'] = $row; if (TRUE === is_object($form)) { $formLabel = $form->getLabel(); $label = LocalizationUtility::translate($formLabel, $extensionKey); $variables['label'] = $label; } $templatePaths = new TemplatePaths($paths); $viewContext = new ViewContext($templatePathAndFilename, $extensionKey, self::CONTROLLER_NAME); $viewContext->setTemplatePaths($templatePaths); $viewContext->setVariables($variables); $view = $this->configurationService->getPreparedExposedTemplateView($viewContext); $existingContentObject = $this->configurationManager->getContentObject(); $contentObject = new ContentObjectRenderer(); $contentObject->start($row, $provider->getTableName($row)); $this->configurationManager->setContentObject($contentObject); $previewContent = $view->renderStandaloneSection(self::PREVIEW_SECTION, $variables, TRUE); $this->configurationManager->setContentObject($existingContentObject); $previewContent = trim($previewContent); return $previewContent; }
/** * @return void */ protected function initializeExtbaseFramework() { // initialize cache manager $this->cacheManager = $GLOBALS['typo3CacheManager']; // inject content object into the configuration manager $this->configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface'); $contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $this->configurationManager->setContentObject($contentObject); $this->typoScriptService->makeTypoScriptBackup(); // load extbase typoscript TypoScriptService::loadTypoScriptFromFile('EXT:extbase/ext_typoscript_setup.txt'); TypoScriptService::loadTypoScriptFromFile('EXT:ap_ldap_auth/ext_typoscript_setup.txt'); $this->configurationManager->setConfiguration($GLOBALS['TSFE']->tmpl->setup); $this->configureObjectManager(); // initialize reflection $this->reflectionService = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Reflection\\ReflectionService'); $this->reflectionService->setDataCache($this->cacheManager->getCache('extbase_reflection')); if (!$this->reflectionService->isInitialized()) { $this->reflectionService->initialize(); } // initialize persistence $this->persistenceManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager'); }
/** * Get preview chunks - header and content - as * array(string $headerContent, string $previewContent, boolean $continueRendering) * * Default implementation renders the Preview section from the template * file that the actual Provider returns for $row, using paths also * determined by $row. Example: fluidcontent's Provider returns files * and paths based on selected "Fluid Content type" and inherits and * uses this method to render a Preview from the template file in the * specific path. This default implementation expects the TYPO3 core * to render the default header, so it returns NULL as $headerContent. * * @param array $row The record data to be analysed for variables to use in a rendered preview * @return array */ public function getPreview(array $row) { $templateSource = $this->getTemplateSource($row); if (TRUE === empty($templateSource)) { return array(NULL, NULL, TRUE); } $extensionKey = $this->getExtensionKey($row); $flexformVariables = $this->getFlexFormValues($row); $templateVariables = $this->getTemplateVariables($row); $variables = RecursiveArrayUtility::merge($templateVariables, $flexformVariables); $paths = $this->getTemplatePaths($row); $form = $this->getForm($row); $formLabel = $form->getLabel(); $label = LocalizationUtility::translate($formLabel, $extensionKey); $variables['label'] = $label; $variables['row'] = $row; $variables['record'] = $row; $view = $this->configurationService->getPreparedExposedTemplateView($extensionKey, 'Content', $paths, $variables); $view->setTemplateSource($templateSource); $existingContentObject = $this->configurationManager->getContentObject(); $contentObject = new ContentObjectRenderer(); $contentObject->start($row, $this->getTableName($row)); $this->configurationManager->setContentObject($contentObject); $previewContent = $view->renderStandaloneSection('Preview', $variables); $this->configurationManager->setContentObject($existingContentObject); $previewContent = trim($previewContent); $headerContent = NULL; return array($headerContent, $previewContent, empty($previewContent)); }