[TASK] Decouple BE module runner and Bootstrap
authorAndreas Wolf <andreas.wolf@typo3.org>
Sat, 9 Feb 2013 19:00:38 +0000 (20:00 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 9 Feb 2013 20:14:01 +0000 (21:14 +0100)
The Bootstrap class is currently registered as a dispatcher for backend
modules (called from mod.php). The dispatching is done in
Bootstrap::callModule(), which does not access the rest of the class
except run() (which is part of the public API).

To make the distinction more clear (and make different dispatchers
possible without logic fuckup), the module running code is moved
to a separate class ModuleRunner.

Change-Id: I7d7571d3204f9da927aa7c3d3cf0cca2b121ef15
Resolves: #45318
Releases: 6.1
Reviewed-on: https://review.typo3.org/18165
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/extbase/Classes/Core/Bootstrap.php
typo3/sysext/extbase/Classes/Core/BootstrapInterface.php
typo3/sysext/extbase/Classes/Core/ModuleRunner.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/Core/ModuleRunnerInterface.php [new file with mode: 0644]
typo3/sysext/extbase/ext_tables.php

index c0e7f71..9b737d8 100644 (file)
@@ -252,46 +252,6 @@ class Bootstrap implements \TYPO3\CMS\Extbase\Core\BootstrapInterface {
                $this->persistenceManager->persistAll();
                $this->reflectionService->shutdown();
        }
-
-       /**
-        * This method forwards the call to run(). This method is invoked by the mod.php
-        * function of TYPO3.
-        *
-        * @param string $moduleSignature
-        * @throws \RuntimeException
-        * @return boolean TRUE, if the request request could be dispatched
-        * @see run()
-        */
-       public function callModule($moduleSignature) {
-               if (!isset($GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature])) {
-                       return FALSE;
-               }
-               $moduleConfiguration = $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature];
-               // Check permissions and exit if the user has no permission for entry
-               $GLOBALS['BE_USER']->modAccess($moduleConfiguration, TRUE);
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id')) {
-                       // Check page access
-                       $permClause = $GLOBALS['BE_USER']->getPagePermsClause(TRUE);
-                       $access = is_array(\TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess((integer) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'), $permClause));
-                       if (!$access) {
-                               throw new \RuntimeException('You don\'t have access to this page', 1289917924);
-                       }
-               }
-               // BACK_PATH is the path from the typo3/ directory from within the
-               // directory containing the controller file. We are using mod.php dispatcher
-               // and thus we are already within typo3/ because we call typo3/mod.php
-               $GLOBALS['BACK_PATH'] = '';
-               $configuration = array(
-                       'extensionName' => $moduleConfiguration['extensionName'],
-                       'pluginName' => $moduleSignature
-               );
-               if (isset($moduleConfiguration['vendorName'])) {
-                       $configuration['vendorName'] = $moduleConfiguration['vendorName'];
-               }
-               $content = $this->run('', $configuration);
-               print $content;
-               return TRUE;
-       }
 }
 
 ?>
index 0628269..f90b2a5 100644 (file)
@@ -42,16 +42,6 @@ interface BootstrapInterface {
         * @api
         */
        public function run($content, $configuration);
-
-       /**
-        * This method forwards the call to run(). This method is invoked by the mod.php
-        * function of TYPO3.
-        *
-        * @param string $moduleSignature
-        * @return boolean TRUE, if the request request could be dispatched
-        * @see run()
-        */
-       public function callModule($moduleSignature);
 }
 
 ?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Core/ModuleRunner.php b/typo3/sysext/extbase/Classes/Core/ModuleRunner.php
new file mode 100644 (file)
index 0000000..e4dd099
--- /dev/null
@@ -0,0 +1,88 @@
+<?php
+namespace TYPO3\CMS\Extbase\Core;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2010-2013 Extbase Team (http://forge.typo3.org/projects/typo3v4-mvc)
+ *  Extbase is a backport of TYPO3 Flow. All credits go to the TYPO3 Flow team.
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Dispatches a request
+ */
+class ModuleRunner implements ModuleRunnerInterface {
+
+       /**
+        * @var \TYPO3\CMS\Extbase\Object\ObjectManager
+        * @inject
+        */
+       protected $objectManager;
+
+       /**
+        * This method forwards the call to Bootstrap's run() method. This method is invoked by the mod.php
+        * function of TYPO3.
+        *
+        * @param string $moduleSignature
+        * @throws \RuntimeException
+        * @return boolean TRUE, if the request request could be dispatched
+        * @see run()
+        */
+       public function callModule($moduleSignature) {
+               if (!isset($GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature])) {
+                       return FALSE;
+               }
+               $moduleConfiguration = $GLOBALS['TBE_MODULES']['_configuration'][$moduleSignature];
+
+               // Check permissions and exit if the user has no permission for entry
+               $GLOBALS['BE_USER']->modAccess($moduleConfiguration, TRUE);
+               if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id')) {
+                       // Check page access
+                       $permClause = $GLOBALS['BE_USER']->getPagePermsClause(TRUE);
+                       $access = is_array(\TYPO3\CMS\Backend\Utility\BackendUtility::readPageAccess((integer) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'), $permClause));
+                       if (!$access) {
+                               throw new \RuntimeException('You don\'t have access to this page', 1289917924);
+                       }
+               }
+
+               // BACK_PATH is the path from the typo3/ directory from within the
+               // directory containing the controller file. We are using mod.php dispatcher
+               // and thus we are already within typo3/ because we call typo3/mod.php
+               $GLOBALS['BACK_PATH'] = '';
+               $configuration = array(
+                       'extensionName' => $moduleConfiguration['extensionName'],
+                       'pluginName' => $moduleSignature
+               );
+               if (isset($moduleConfiguration['vendorName'])) {
+                       $configuration['vendorName'] = $moduleConfiguration['vendorName'];
+               }
+
+               $bootstrap = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Core\\BootstrapInterface');
+               $content = $bootstrap->run('', $configuration);
+               print $content;
+
+               return TRUE;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Core/ModuleRunnerInterface.php b/typo3/sysext/extbase/Classes/Core/ModuleRunnerInterface.php
new file mode 100644 (file)
index 0000000..d973a18
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+namespace TYPO3\CMS\Extbase\Core;
+
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2010-2013 Extbase Team (http://forge.typo3.org/projects/typo3v4-mvc)
+ *  Extbase is a backport of TYPO3 Flow. All credits go to the TYPO3 Flow team.
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Interface for module runners that can execute requests to Extbase controllers in the backend
+ */
+interface ModuleRunnerInterface {
+       /**
+        * Initializes and runs a module.
+        *
+        * @param string $moduleSignature
+        * @throws \RuntimeException
+        * @return boolean TRUE, if the request request could be dispatched
+        * @see run()
+        */
+       public function callModule($moduleSignature);
+}
+
+?>
\ No newline at end of file
index f0e93d8..667e602 100644 (file)
@@ -4,7 +4,7 @@ if (!defined('TYPO3_MODE')) {
 }
 if (TYPO3_MODE == 'BE') {
        // register Extbase dispatcher for modules
-       $TBE_MODULES['_dispatcher'][] = 'TYPO3\\CMS\\Extbase\\Core\\BootstrapInterface';
+       $TBE_MODULES['_dispatcher'][] = 'TYPO3\\CMS\\Extbase\\Core\\ModuleRunnerInterface';
 }
 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['extbase'][] = 'TYPO3\\CMS\\Extbase\\Utility\\ExtbaseRequirementsCheckUtility';
 if (!isset($TCA['fe_users']['ctrl']['type'])) {