File tree Expand file tree Collapse file tree 2 files changed +26
-3
lines changed
CodeIgniter/Framework/core Expand file tree Collapse file tree 2 files changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -403,10 +403,24 @@ function &get_instance()
403403$ class = ucfirst ($ RTR ->class );
404404$ method = $ RTR ->method ;
405405
406- if (empty ($ class ) or !file_exists (APPPATH . 'controllers/ ' . $ RTR ->directory . $ class . '.php ' )) {
406+ // Specify default paths to load controllers when they are not module controllers
407+ $ corePathController = APPPATH . 'controllers/ ' . $ RTR ->directory . $ class . '.php ' ;
408+ $ appRootController = APPROOT . 'Controllers/ ' . $ RTR ->directory . $ class . '.php ' ;
409+
410+ if (
411+ (empty ($ class ) or !file_exists ($ corePathController ))
412+ and (empty ($ class ) or !file_exists ($ appRootController ))
413+ ) {
407414 $ e404 = true ;
408415} else {
409- require_once (APPPATH . 'controllers/ ' . $ RTR ->directory . $ class . '.php ' );
416+
417+ if (file_exists ($ corePathController )) {
418+ require_once ($ corePathController );
419+ }
420+
421+ if (file_exists ($ appRootController )) {
422+ require_once ($ appRootController );
423+ }
410424
411425 if (!class_exists ($ class , false ) or $ method [0 ] === '_ ' or method_exists ('CI_Controller ' , $ method )) {
412426 $ e404 = true ;
Original file line number Diff line number Diff line change @@ -191,7 +191,12 @@ public function locate($segments)
191191 }
192192
193193 if ( ! empty ($ this ->directory )) return ;
194-
194+
195+ // /* controller exists in App/Controllers directory? */
196+ // if (is_file(APPROOT . 'Controllers/' . ucfirst($module) . $ext)) {
197+ // $directory = $module;
198+ // }
199+
195200 /* controller exists in commands directory? */
196201 if (is_file (APPPATH . 'controllers/ ' .$ commands_directory .'/ ' . ucfirst ($ module ) . $ ext )) {
197202 $ directory = $ module ;
@@ -229,6 +234,10 @@ public function locate($segments)
229234 return array_slice ($ segments , 1 );
230235 }
231236
237+ if (is_file (APPROOT . 'Controllers/ ' . ucfirst ($ module ) . $ ext )) {
238+ return $ segments ;
239+ }
240+
232241 /* application controller exists? */
233242 if (is_file (APPPATH .'controllers/ ' .ucfirst ($ module ).$ ext ))
234243 {
You can’t perform that action at this time.
0 commit comments