[BUGFIX] EXT:beuser must have frontend root TS template
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 7 Aug 2012 21:50:27 +0000 (23:50 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 7 Aug 2012 22:02:38 +0000 (00:02 +0200)
Due to the current bootstrap structure of extbase, an extbase
based backend module must have a TypoScript frontend root template.
The patch introduces a descriptive exception message in case
this is not given.

Furthermore, the dependency injection configuration is moved
to an own file within the extension and moved to module.beuser
TS instead of global extbase scope.

Change-Id: Id621b856a3ad2297a20612e911186be473a63602
Resolves: #39602
Releases: 6.0
Reviewed-on: http://review.typo3.org/13509
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/beuser/Classes/Controller/BackendUserController.php
typo3/sysext/beuser/Configuration/TypoScript/setup.txt [new file with mode: 0644]
typo3/sysext/beuser/ext_typoscript_setup.txt

index c65e315..b853556 100755 (executable)
@@ -84,6 +84,28 @@ class Tx_Beuser_Controller_BackendUserController extends Tx_Extbase_MVC_Controll
        }
 
        /**
+        * Initialize actions
+        *
+        * @throws RuntimeException
+        * @return void
+        */
+       public function initializeAction() {
+                       // @TODO: Extbase backend modules relies on frontend TypoScript for view, persistence
+                       // and settings. Thus, we need a TypoScript root template, that then loads the
+                       // ext_typoscript_setup.txt file of this module. This is nasty, but can not be
+                       // circumvented until there is a better solution in extbase.
+                       // For now we throw an exception if no settings are detected.
+               if (empty($this->settings)) {
+                       throw new RuntimeException(
+                               'No settings detected. This module can not work then. '.
+                               'This usually happens if there is no frontend TypoScript template with root flag set. ' .
+                               'Please create a frontend page with a TypoScript root template.',
+                               1344375003
+                       );
+               }
+       }
+
+       /**
         * Displays all BackendUsers
         * - Switch session to different user
         *
diff --git a/typo3/sysext/beuser/Configuration/TypoScript/setup.txt b/typo3/sysext/beuser/Configuration/TypoScript/setup.txt
new file mode 100644 (file)
index 0000000..0cebb69
--- /dev/null
@@ -0,0 +1,35 @@
+module.tx_beuser {
+       persistence {
+               storagePid = 0
+
+               classes {
+                       Tx_Beuser_Domain_Model_BackendUser {
+                               mapping {
+                                       tableName = be_users
+                                       columns {
+                                               allowed_languages.mapOnProperty = allowedLanguages
+                                               file_mountpoints.mapOnProperty = fileMountPoints
+                                               db_mountpoints.mapOnProperty = dbMountPoints
+                                               usergroup.mapOnProperty = backendUserGroups
+                                       }
+                               }
+                       }
+                       Tx_Beuser_Domain_Model_BackendUserGroup {
+                               mapping {
+                                       tableName = be_groups
+                                       columns {
+                                               subgroup.mapOnProperty = subGroups
+                                       }
+                               }
+                       }
+               }
+       }
+
+       settings {
+                       // This is a dummy entry. It is used in  Tx_Beuser_Controller_BackendUserController
+                       // to test that some TypoScript configuration is set.
+                       // This entry can be removed if extbase setup is made frontend TS independant
+                       // or if there are other settings set.
+               dummy = foo
+       }
+}
\ No newline at end of file
index 3edab89..f07dc5d 100755 (executable)
@@ -1,31 +1 @@
-module.tx_beuser {
-       persistence {
-               storagePid = 0
-       }
-}
-
-config.tx_extbase {
-       persistence {
-               classes {
-                       Tx_Beuser_Domain_Model_BackendUser {
-                               mapping {
-                                       tableName = be_users
-                                       columns {
-                                               allowed_languages.mapOnProperty = allowedLanguages
-                                               file_mountpoints.mapOnProperty = fileMountPoints
-                                               db_mountpoints.mapOnProperty = dbMountPoints
-                                               usergroup.mapOnProperty = backendUserGroups
-                                       }
-                               }
-                       }
-                       Tx_Beuser_Domain_Model_BackendUserGroup {
-                               mapping {
-                                       tableName = be_groups
-                                       columns {
-                                               subgroup.mapOnProperty = subGroups
-                                       }
-                               }
-                       }
-               }
-       }
-}
\ No newline at end of file
+<INCLUDE_TYPOSCRIPT: source="FILE:EXT:beuser/Configuration/TypoScript/setup.txt">
\ No newline at end of file