[TASK] Set about module free from Extbase 14/55714/6
authorBenni Mack <benni@typo3.org>
Wed, 14 Feb 2018 13:04:54 +0000 (14:04 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 14 Feb 2018 21:31:56 +0000 (22:31 +0100)
The whole Extbase stack for the about module
is not necessary, as there is only one action
in this controller, and it's a simple Fluid
action.

The module name is kept as "help_AboutAbout"
due to the uncool naming handling of Extbase magic.

Resolves: #83899
Releases: master
Change-Id: I6353c30528d619f849ea77774b16ff0eb499e820
Reviewed-on: https://review.typo3.org/55714
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/about/Classes/Controller/AboutController.php
typo3/sysext/about/ext_tables.php

index d0b863c..6b7d91a 100644 (file)
@@ -14,42 +14,45 @@ namespace TYPO3\CMS\About\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Backend\Module\ModuleLoader;
+use TYPO3\CMS\Backend\Template\ModuleTemplate;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Backend\View\BackendTemplateView;
+use TYPO3\CMS\Core\Http\HtmlResponse;
 use TYPO3\CMS\Core\Package\PackageManager;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
-use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
-use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
+use TYPO3\CMS\Fluid\View\StandaloneView;
+use TYPO3Fluid\Fluid\View\ViewInterface;
 
 /**
- * Module 'about' shows some standard information for TYPO3 CMS: About-text, version number, available modules and so on.
+ * Module 'about' shows some standard information for TYPO3 CMS:
+ * About-text, version number, available modules and so on.
  */
-class AboutController extends ActionController
+class AboutController
 {
     /**
-     * @var ViewInterface
+     * ModuleTemplate object
+     *
+     * @var ModuleTemplate
      */
-    protected $defaultViewObjectName = BackendTemplateView::class;
+    protected $moduleTemplate;
 
     /**
-     * Set up the doc header properly here
-     *
-     * @param ViewInterface $view
+     * @var ViewInterface
      */
-    protected function initializeView(ViewInterface $view)
-    {
-        /** @var BackendTemplateView $view */
-        parent::initializeView($view);
-        // Disable Path
-        $view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation([]);
-    }
+    protected $view;
 
     /**
      * Main action: Show standard information
+     *
+     * @param ServerRequestInterface $request the incoming PSR-7 request
+     * @return ResponseInterface the HTML output
      */
-    public function indexAction()
+    public function indexAction(ServerRequestInterface $request): ResponseInterface
     {
+        $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
+        $this->initializeView('index');
         $warnings = [];
         // Hook for additional warnings
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] ?? [] as $className) {
@@ -68,6 +71,9 @@ class AboutController extends ActionController
             'warnings' => $warnings,
             'modules' => $this->getModulesData()
         ]);
+
+        $this->moduleTemplate->setContent($this->view->render());
+        return new HtmlResponse($this->moduleTemplate->renderContent());
     }
 
     /**
@@ -76,7 +82,7 @@ class AboutController extends ActionController
      *
      * @return array
      */
-    protected function getModulesData()
+    protected function getModulesData(): array
     {
         $loadedModules = GeneralUtility::makeInstance(ModuleLoader::class);
         $loadedModules->observeWorkspaces = true;
@@ -103,7 +109,7 @@ class AboutController extends ActionController
      * @param string $moduleName Name of the main module
      * @return array
      */
-    protected function getSubModuleData(ModuleLoader $loadedModules, $moduleName)
+    protected function getSubModuleData(ModuleLoader $loadedModules, $moduleName): array
     {
         $subModulesData = [];
         foreach ($loadedModules->modules[$moduleName]['sub'] as $subModuleName => $subModuleInfo) {
@@ -142,4 +148,18 @@ class AboutController extends ActionController
         }
         return $extensions;
     }
+
+    /**
+     * Initializes the view by setting the templateName
+     *
+     * @param string $templateName
+     */
+    protected function initializeView(string $templateName)
+    {
+        $this->view = GeneralUtility::makeInstance(StandaloneView::class);
+        $this->view->setTemplate($templateName);
+        $this->view->setTemplateRootPaths(['EXT:about/Resources/Private/Templates/About']);
+        $this->view->setPartialRootPaths(['EXT:about/Resources/Private/Partials']);
+        $this->view->setLayoutRootPaths(['EXT:about/Resources/Private/Layouts']);
+    }
 }
index 5d0bd6c..c42bd22 100644 (file)
@@ -1,16 +1,15 @@
 <?php
 defined('TYPO3_MODE') or die();
 
-\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule(
-    'TYPO3.CMS.About',
+\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModule(
     'help',
-    'about',
+    'AboutAbout',
     'top',
+    null,
     [
-        'About' => 'index'
-    ],
-    [
+        'routeTarget' => \TYPO3\CMS\About\Controller\AboutController::class . '::indexAction',
         'access' => 'user,group',
+        'name' => 'help_AboutAbout',
         'icon' => 'EXT:about/Resources/Public/Icons/module-about.svg',
         'labels' => 'LLL:EXT:about/Resources/Private/Language/Modules/about.xlf'
     ]