/** * Executes the modules configured via Extbase * * @param string $moduleName * @return Response A PSR-7 response object * @throws \RuntimeException */ protected function dispatchModule($moduleName) { $moduleConfiguration = $this->getModuleConfiguration($moduleName); // Check permissions and exit if the user has no permission for entry $this->backendUserAuthentication->modAccess($moduleConfiguration, true); $id = isset($this->request->getQueryParams()['id']) ? $this->request->getQueryParams()['id'] : $this->request->getParsedBody()['id']; if ($id && MathUtility::canBeInterpretedAsInteger($id)) { // Check page access $permClause = $this->backendUserAuthentication->getPagePermsClause(true); $access = is_array(BackendUtility::readPageAccess((int) $id, $permClause)); if (!$access) { throw new \RuntimeException('You don\'t have access to this page', 1289917924); } } /** @var Response $response */ $response = GeneralUtility::makeInstance(Response::class); // Use Core Dispatching if (isset($moduleConfiguration['routeTarget'])) { $dispatcher = GeneralUtility::makeInstance(Dispatcher::class); $this->request = $this->request->withAttribute('target', $moduleConfiguration['routeTarget']); $response = $dispatcher->dispatch($this->request, $response); } else { // extbase module $configuration = array('extensionName' => $moduleConfiguration['extensionName'], 'pluginName' => $moduleName); if (isset($moduleConfiguration['vendorName'])) { $configuration['vendorName'] = $moduleConfiguration['vendorName']; } // Run Extbase $bootstrap = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Core\Bootstrap::class); $content = $bootstrap->run('', $configuration); $response->getBody()->write($content); } return $response; }
/** * Calls traditional modules which are identified by having a index.php in their directory * and were previously located within the global scope. * * @param string $moduleName * @return bool */ protected function callTraditionalModule($moduleName) { $moduleBasePath = $this->moduleRegistry['_PATHS'][$moduleName]; $GLOBALS['MCONF'] = $moduleConfiguration = $this->getModuleConfiguration($moduleName); if (!empty($moduleConfiguration['access'])) { $this->backendUserAuthentication->modAccess($moduleConfiguration, TRUE); } if (file_exists($moduleBasePath . 'index.php')) { global $SOBE; require $moduleBasePath . 'index.php'; return TRUE; } return FALSE; }
/** * Calls traditional modules which are identified by having an index.php in their directory * and were previously located within the global scope. * * @param string $moduleName * @return bool Returns TRUE if the module was executed */ protected function callTraditionalModule($moduleName) { $moduleBasePath = $this->moduleRegistry['_PATHS'][$moduleName]; // Some modules still rely on this global configuration array in a conf.php file // load configuration from an existing conf.php file inside the same directory if (file_exists($moduleBasePath . 'conf.php')) { require $moduleBasePath . 'conf.php'; $moduleConfiguration = $MCONF; } else { $moduleConfiguration = $this->getModuleConfiguration($moduleName); } $GLOBALS['MCONF'] = $moduleConfiguration; if (!empty($moduleConfiguration['access'])) { $this->backendUserAuthentication->modAccess($moduleConfiguration, true); } if (file_exists($moduleBasePath . 'index.php')) { global $SOBE; require $moduleBasePath . 'index.php'; return true; } return false; }