/** * Initializes and runs an extbase controller * * @param string $extensionName Name of extension, in UpperCamelCase * @param string $controller Name of controller, in UpperCamelCase * @param string $action Optional name of action, in lowerCamelCase * @param string $pluginName Optional name of plugin. Default is 'Pi1' * @param array $settings Optional array of settings to use in controller * @param int $pageUid Uid of current page * @param string $vendorName VendorName * @return string output of controller's action */ protected function runExtbaseController($extensionName, $controller, $action = 'index', $pluginName = 'Pi1', $settings = array(), $pageUid = 0, $vendorName = 'PwCommentsTeam') { $GLOBALS['TT'] = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TimeTracker\\TimeTracker'); $GLOBALS['TSFE'] = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $pageUid, 0); $GLOBALS['TSFE']->sys_page = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository'); $GLOBALS['TSFE']->initTemplate(); $rootline = $GLOBALS['TSFE']->sys_page->getRootLine($pageUid); $GLOBALS['TSFE']->tmpl->start($rootline); $GLOBALS['TSFE']->getConfigArray(); $pluginSettings = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_pwcomments.']; $pwCommentsTypoScript = $pluginSettings['settings.']; \TYPO3\CMS\Frontend\Utility\EidUtility::initLanguage('de'); \TYPO3\CMS\Frontend\Utility\EidUtility::initTCA(); \TYPO3\CMS\Frontend\Utility\EidUtility::initExtensionTCA('pw_comments'); if (unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['pw_comments'])) { $settings = array_merge($settings, unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['pw_comments'])); } $settings = array_merge($settings, $pwCommentsTypoScript); $bootstrap = new \TYPO3\CMS\Extbase\Core\Bootstrap(); $bootstrap->cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $extensionTyposcriptSetup = $this->getExtensionTyposcriptSetup(); $localLangArray = array(); if (is_array($pluginSettings['_LOCAL_LANG.'])) { $typoScriptService = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService'); $localLangArray = $typoScriptService->convertTypoScriptArrayToPlainArray($pluginSettings['_LOCAL_LANG.']); } $configuration = array('pluginName' => $pluginName, 'extensionName' => $extensionName, 'controller' => $controller, 'vendorName' => $vendorName, 'controllerConfiguration' => array($controller), 'action' => $action, 'mvc' => array('requestHandlers' => array('TYPO3\\CMS\\Extbase\\Mvc\\Web\\FrontendRequestHandler' => 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\FrontendRequestHandler')), 'settings' => $settings, 'persistence' => $extensionTyposcriptSetup['plugin']['tx_pwcomments']['persistence'], '_LOCAL_LANG' => $localLangArray); return $bootstrap->run('', $configuration); }
/** * @return void */ public function setUp() { $this->testingFramework = new \Tx_Phpunit_Framework('fe_users'); $pageUid = $this->testingFramework->createFrontEndPage(); $this->testingFramework->createTemplate($pageUid, array('include_static_file' => 'EXT:sf_register/Configuration/TypoScript/')); $this->testingFramework->createFakeFrontEnd($pageUid); $extensionName = 'SfRegister'; $pluginName = 'Form'; $extensionSettings = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]; $extensionSettings['modules'][$pluginName]['controllers']['FeuserCreate'] = array('actions' => array('form', 'preview', 'proxy', 'save', 'confirm', 'removeImage'), 'nonCacheableActions' => array('form', 'preview', 'proxy', 'save', 'confirm', 'removeImage')); $bootstrap = new \TYPO3\CMS\Extbase\Core\Bootstrap(); $bootstrap->run('', array('userFunc' => '\\TYPO3\\CMS\\Extbase\\Core\\Bootstrap->run', 'extensionName' => $extensionName, 'pluginName' => $pluginName)); /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ $objectManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class); $this->fixture = new \Evoweb\SfRegister\Domain\Repository\FrontendUserRepository($objectManager); }
$TSFE->getConfigArray(); \TYPO3\CMS\Core\Core\Bootstrap::getInstance(); $TSFE->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\\TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); $TSFE->settingLanguage(); $TSFE->settingLocale(); if (!$TSFE->baseUrl) { $baseUrl = $GLOBALS['TSFE']->config['config']['baseURL']; $TSFE->baseUrl = $baseUrl ? $baseUrl : $_SERVER['HTTP_HOST']; } $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\\TYPO3\\CMS\\Extbase\\Object\\ObjectManager'); /** * Initialize Extbase bootstap */ $bootstrapConf['extensionName'] = 'Nnfesubmit'; $bootstrapConf['pluginName'] = 'Pi1'; $bootstrap = new TYPO3\CMS\Extbase\Core\Bootstrap(); $bootstrap->initialize($bootstrapConf); $bootstrap->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('\\TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer'); /** * Build the request */ $request = $objectManager->get('\\TYPO3\\CMS\\Extbase\\Mvc\\Request'); $request->setControllerVendorName('Nng'); $request->setcontrollerExtensionName('Nnfesubmit'); $request->setPluginName('Pi1'); $request->setControllerName('Eid'); $request->setControllerActionName('processRequest'); $request->setArguments(array_merge($_POST, $_GET)); $response = $objectManager->create('\\TYPO3\\CMS\\Extbase\\Mvc\\ResponseInterface'); $dispatcher = $objectManager->get('\\TYPO3\\CMS\\Extbase\\Mvc\\Dispatcher'); $dispatcher->dispatch($request, $response);