@@ -56,6 +56,24 @@ public function serves($sitePath, $siteName, $uri) {
5656 return file_exists ($ typo3Dir ) && is_dir ($ typo3Dir );
5757 }
5858
59+ /**
60+ * Take any steps necessary before loading the front controller for this driver.
61+ *
62+ * @param string $sitePath
63+ * @param string $siteName
64+ * @param string $uri
65+ * @return void
66+ */
67+ public function beforeLoading ($ sitePath , $ siteName , $ uri ) {
68+ // without modifying the URI, redirect if necessary
69+ $ this ->handleRedirectBackendShorthandUris ($ uri );
70+
71+ $ _SERVER ['SERVER_NAME ' ] = "{$ siteName }.dev " ;
72+ $ _SERVER ['DOCUMENT_URI ' ] = $ uri ;
73+ $ _SERVER ['SCRIPT_NAME ' ] = $ uri ;
74+ $ _SERVER ['PHP_SELF ' ] = $ uri ;
75+ }
76+
5977 /**
6078 * Determine if the incoming request is for a static file. That is, it is
6179 * no PHP script file and the URI points to a valid file (no folder) on
@@ -115,9 +133,6 @@ private function isAccessAuthorized($uri) {
115133 * @return string
116134 */
117135 public function frontControllerPath ($ sitePath , $ siteName , $ uri ) {
118- // without modifying the URI, redirect if necessary
119- $ this ->handleRedirectBackendShorthandUris ($ uri );
120-
121136 // from now on, remove trailing / for convenience for all the following join operations
122137 $ uri = rtrim ($ uri , '/ ' );
123138
@@ -126,7 +141,7 @@ public function frontControllerPath($sitePath, $siteName, $uri) {
126141 if (is_dir ($ absoluteFilePath )) {
127142 if (file_exists ("{$ absoluteFilePath }/index.php " )) {
128143 // this folder can be served by index.php
129- return $ this ->serveScript ($ sitePath , $ siteName , "{$ uri }/index.php " );
144+ return $ this ->serveScript ($ sitePath , "{$ uri }/index.php " );
130145 }
131146
132147 if (file_exists ("{$ absoluteFilePath }/index.html " )) {
@@ -136,12 +151,12 @@ public function frontControllerPath($sitePath, $siteName, $uri) {
136151 }
137152 elseif (pathinfo ($ absoluteFilePath , PATHINFO_EXTENSION ) === 'php ' ) {
138153 // this file can be served directly
139- return $ this ->serveScript ($ sitePath , $ siteName , $ uri );
154+ return $ this ->serveScript ($ sitePath , $ uri );
140155 }
141156 }
142157
143158 // the global index.php will handle all other cases
144- return $ this ->serveScript ($ sitePath , $ siteName , '/index.php ' );
159+ return $ this ->serveScript ($ sitePath , '/index.php ' );
145160 }
146161
147162 /**
@@ -170,21 +185,16 @@ private function handleRedirectBackendShorthandUris($uri) {
170185 * the specified URI and returns it absolute file path.
171186 *
172187 * @param string $sitePath
173- * @param string $siteName
174188 * @param string $uri
175189 *
176190 * @return string
177191 */
178- private function serveScript ($ sitePath , $ siteName , $ uri ) {
192+ private function serveScript ($ sitePath , $ uri ) {
179193 $ docroot = "{$ sitePath }{$ this ->documentRoot }" ;
180194 $ abspath = "{$ docroot }{$ uri }" ;
181195
182- $ _SERVER ['SERVER_NAME ' ] = "{$ siteName }.dev " ;
183196 $ _SERVER ['DOCUMENT_ROOT ' ] = $ docroot ;
184- $ _SERVER ['DOCUMENT_URI ' ] = $ uri ;
185197 $ _SERVER ['SCRIPT_FILENAME ' ] = $ abspath ;
186- $ _SERVER ['SCRIPT_NAME ' ] = $ uri ;
187- $ _SERVER ['PHP_SELF ' ] = $ uri ;
188198
189199 return $ abspath ;
190200 }
0 commit comments