[TASK] Move EXT:version entrypoint to Routing 26/42726/4
authorBenjamin Mack <benni@typo3.org>
Tue, 18 Aug 2015 18:04:31 +0000 (20:04 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Tue, 18 Aug 2015 18:52:39 +0000 (20:52 +0200)
Resolves: #69166
Releases: master
Change-Id: I7fe803ff352464b984ff7008e6ed1aad2c1bdada
Reviewed-on: http://review.typo3.org/42726
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/version/Classes/Controller/VersionModuleController.php
typo3/sysext/version/Configuration/Backend/Routes.php [new file with mode: 0644]
typo3/sysext/version/Modules/Version/conf.php [deleted file]
typo3/sysext/version/Modules/Version/index.php [deleted file]
typo3/sysext/version/ext_tables.php

index ffe8e40..de1d1be 100644 (file)
@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Version\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Psr\Http\Message\ServerRequestInterface;
+use TYPO3\CMS\Core\Http\Response;
 use TYPO3\CMS\Core\Imaging\Icon;
 use TYPO3\CMS\Core\Imaging\IconFactory;
 use TYPO3\CMS\Core\Utility\ArrayUtility;
@@ -25,7 +27,7 @@ use TYPO3\CMS\Backend\Utility\IconUtility;
 /**
  * Versioning module, including workspace management
  */
-class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass {
+class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass implements \TYPO3\CMS\Core\Http\ControllerInterface {
 
        /**
         * Module configuration
@@ -112,10 +114,18 @@ class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
        protected $iconFactory;
 
        /**
+        * The name of the module
+        *
+        * @var string
+        */
+       protected $moduleName = 'web_txversionM1';
+
+       /**
         * Initialize language files
         */
        public function __construct() {
                $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
+               $GLOBALS['SOBE'] = $this;
                $GLOBALS['LANG']->includeLLFile('EXT:version/Resources/Private/Language/locallang.xlf');
        }
 
@@ -126,7 +136,7 @@ class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
         */
        public function menuConfig() {
                // CLEANSE SETTINGS
-               $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], 'ses');
+               $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->moduleName, 'ses');
        }
 
        /**
@@ -143,7 +153,7 @@ class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
                        'CONTENT' => ''
                );
                // Setting module configuration:
-               $this->MCONF = $GLOBALS['MCONF'];
+               $this->MCONF['name'] = $this->moduleName;
                $this->REQUEST_URI = str_replace('&sendToReview=1', '', GeneralUtility::getIndpEnv('REQUEST_URI'));
                // Draw the header.
                $this->doc = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Template\DocumentTemplate::class);
@@ -212,8 +222,10 @@ class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
         * Outputs accumulated module content to browser.
         *
         * @return void
+        * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8
         */
        public function printContent() {
+               GeneralUtility::logDeprecatedFunction();
                echo $this->content;
        }
 
@@ -238,7 +250,7 @@ class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
                                </a>';
                        // Shortcut
                        if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
-                               $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->MCONF['name']);
+                               $buttons['shortcut'] = $this->doc->makeShortcutIcon('id, edit_record, pointer, new_unique_uid, search_field, search_levels, showLimit', implode(',', array_keys($this->MOD_MENU)), $this->moduleName);
                        }
                        // If access to Web>List for user, then link to that module.
                        $buttons['record_list'] = BackendUtility::getListViewLink(array(
@@ -499,7 +511,7 @@ class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
                        // If another page module was specified, replace the default Page module with the new one
                        $newPageModule = trim($GLOBALS['BE_USER']->getTSConfigVal('options.overridePageModule'));
                        $pageModule = BackendUtility::isModuleSetInTBE_MODULES($newPageModule) ? $newPageModule : 'web_layout';
-                       // Perform some acccess checks:
+                       // Perform some access checks:
                        $a_wl = $GLOBALS['BE_USER']->check('modules', 'web_list');
                        $a_wp = $GLOBALS['BE_USER']->check('modules', $pageModule);
                        $adminLink .= '<a class="btn btn-default" href="#" onclick="top.loadEditId(' . $row['uid'] . ');top.goToModule(\'' . $pageModule . '\'); return false;">' . $this->iconFactory->getIcon('actions-page-open', Icon::SIZE_SMALL) . '</a>';
@@ -516,4 +528,20 @@ class VersionModuleController extends \TYPO3\CMS\Backend\Module\BaseScriptClass
                return '<div class="btn-group btn-group-sm" role="group">' . $adminLink . '</div>';
        }
 
+
+       /**
+        * Injects the request object for the current request and gathers all data
+        *
+        * @param ServerRequestInterface $request
+        * @return \Psr\Http\Message\ResponseInterface $response
+        */
+       public function processRequest(ServerRequestInterface $request) {
+               $this->init();
+               $this->main();
+
+               /** @var Response $response */
+               $response = GeneralUtility::makeInstance(Response::class);
+               $response->getBody()->write($this->content);
+               return $response;
+       }
 }
diff --git a/typo3/sysext/version/Configuration/Backend/Routes.php b/typo3/sysext/version/Configuration/Backend/Routes.php
new file mode 100644 (file)
index 0000000..9ab3a7c
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * Definitions for routes provided by EXT:version
+ */
+return [
+       // Register version_click_module entry point
+       'web_txversionM1' => [
+               'path' => '/record/versions/',
+               'controller' => \TYPO3\CMS\Version\Controller\VersionModuleController::class
+       ]
+];
diff --git a/typo3/sysext/version/Modules/Version/conf.php b/typo3/sysext/version/Modules/Version/conf.php
deleted file mode 100644 (file)
index 7bcbe65..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-<?php
-$MCONF['name'] = 'web_txversionM1';
-$MCONF['script'] = '_DISPATCH';
\ No newline at end of file
diff --git a/typo3/sysext/version/Modules/Version/index.php b/typo3/sysext/version/Modules/Version/index.php
deleted file mode 100644 (file)
index eed2deb..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-
-$GLOBALS['SOBE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Version\Controller\VersionModuleController::class);
-$GLOBALS['SOBE']->init();
-$GLOBALS['SOBE']->main();
-$GLOBALS['SOBE']->printContent();
index 4a3ce93..56fa5f5 100644 (file)
@@ -1,17 +1,8 @@
 <?php
 defined('TYPO3_MODE') or die();
 
-if (TYPO3_MODE == 'BE') {
-       if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces')) {
-               // Register version_click_module
-               \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
-                       'web_txversionM1',
-                       'EXT:version/Modules/Version/'
-               );
-
-               $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'][] = array(
-                       'name' => \TYPO3\CMS\Version\ClickMenu\VersionClickMenu::class,
-               );
-       }
-
+if (TYPO3_MODE == 'BE' && !\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('workspaces')) {
+       $GLOBALS['TBE_MODULES_EXT']['xMOD_alt_clickmenu']['extendCMclasses'][] = array(
+               'name' => \TYPO3\CMS\Version\ClickMenu\VersionClickMenu::class,
+       );
 }