/** * Action initializer * * @return void */ protected function initializeAction() { $pageId = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $persistenceConfiguration = ['persistence' => ['storagePid' => $pageId]]; $this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration)); }
/** * Builds a CLI request object from a command line. * * The given command line may be a string (e.g. "myextension:foo do-that-thing --force") or * an array consisting of the individual parts. The array must not include the script * name (like in $argv) but start with command right away. * * @param mixed $commandLine The command line, either as a string or as an array * @param string $callingScript The calling script (usually ./typo3/cli_dispatch.phpsh) * @return \TYPO3\CMS\Extbase\Mvc\Cli\Request The CLI request as an object */ public function build($commandLine = '', $callingScript = './typo3/cli_dispatch.phpsh extbase') { $request = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Cli\Request::class); $request->setCallingScript($callingScript); $request->setControllerObjectName(\TYPO3\CMS\Extbase\Command\HelpCommandController::class); $rawCommandLineArguments = is_array($commandLine) ? $commandLine : explode(' ', $commandLine); if (empty($rawCommandLineArguments)) { $request->setControllerCommandName('helpStub'); return $request; } $commandIdentifier = trim(array_shift($rawCommandLineArguments)); try { $command = $this->commandManager->getCommandByIdentifier($commandIdentifier); $this->configurationManager->setConfiguration(array('extensionName' => $command->getExtensionName())); } catch (\TYPO3\CMS\Extbase\Mvc\Exception\CommandException $exception) { $request->setArgument('exception', $exception); $request->setControllerCommandName('error'); return $request; } $controllerObjectName = $command->getControllerClassName(); $controllerCommandName = $command->getControllerCommandName(); $request->setControllerObjectName($controllerObjectName); $request->setControllerCommandName($controllerCommandName); list($commandLineArguments, $exceedingCommandLineArguments) = $this->parseRawCommandLineArguments($rawCommandLineArguments, $controllerObjectName, $controllerCommandName); $request->setArguments($commandLineArguments); $request->setExceedingArguments($exceedingCommandLineArguments); return $request; }
/** * 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(); } }
/** * 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); }
/** * Action initializer * * @return void */ protected function initializeAction() { # $this->pageId = (int)t3lib_div::_GP('id'); $this->pageId = (int) $GLOBALS['TSFE']->id; $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $persistenceConfiguration = array('persistence' => array('storagePid' => $this->pageId)); $this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration)); #debug($this->request->getArguments()); }
protected function initializeAction() { if ($GLOBALS['TSFE'] === NULL) { $this->pageId = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'); } else { $this->pageId = $GLOBALS['TSFE']->id; } $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $persistenceConfiguration = array('persistence' => array('storagePid' => $this->pageId)); $this->configurationManager->setConfiguration(array_merge($frameworkConfiguration, $persistenceConfiguration)); $this->piVars = $this->request->getArguments(); }
/** * A function for injecting dependencies. Should be called first * thing within the overridden 'execute' method. * * @param $extensionName * @param $pluginName */ protected function initialize($extensionName, $pluginName) { $injectionService = GeneralUtility::makeInstance('CIC\\Cicbase\\Service\\InjectionService'); $injectionService->doInjection($this); // Grab the settings array $this->configurationManager->setConfiguration(array('extensionName' => $extensionName, 'pluginName' => $pluginName)); $this->settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS); if (!$this->settings) { $configuration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); $settings = $configuration['plugin.']['tx_' . strtolower($extensionName) . '.']['settings.']; $this->settings = $this->typoscriptService->convertTypoScriptArrayToPlainArray($settings); } }
/** * Set storage pid in BE * * Only needed when the class is called or injected in a BE context, e.g. a hook. * Without the generation of the TS is based upon the next root page (default * extbase behaviour) and repositories won't work as expected. * * @param $pageUid * * @return void */ public function setPageUid($pageUid) { if (TYPO3_MODE === 'BE') { $currentPid['persistence']['storagePid'] = (int) $pageUid; $this->configurationManager->setConfiguration(array_merge($this->getFrameworkSettings(), $currentPid)); GeneralUtility::_GETset((int) $pageUid, 'id'); } }
/** * Checks if the startingpoint via flexform is set and overrides the storagePid * if nothing is set, even the storagePid, it uses the current page as storagePid * * @return void */ protected function checkStoragePid() { $extName = $this->request->getControllerExtensionName(); $pluginName = $this->request->getPluginName(); $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extName, $pluginName); // Override the storagePid if (!empty($this->settings['startingpoint'])) { $frameworkConfiguration['persistence']['storagePid'] = $this->settings['startingpoint']; $this->configurationManager->setConfiguration($frameworkConfiguration); } elseif (empty($frameworkConfiguration['persistence']['storagePid'])) { $frameworkConfiguration['persistence']['storagePid'] = $GLOBALS['TSFE']->id; $this->configurationManager->setConfiguration($frameworkConfiguration); } }
/** * @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'); }