Exemple #1
0
 public function Gdn_Dispatcher_BeforeDispatch_Handler($Sender)
 {
     $Request = Gdn::Request();
     $RequestUri = $Request->RequestUri();
     if (Gdn::Router()->GetRoute($RequestUri) === False) {
         $RequestArgs = SplitUpString($RequestUri, '/', 'strtolower');
         if (array_key_exists(0, $RequestArgs)) {
             $ApplicationFolders = $Sender->EnabledApplicationFolders();
             $bFoundApplication = in_array($RequestArgs[0], $ApplicationFolders);
             if ($bFoundApplication === False) {
                 $PathParts = array('controllers', 'class.' . $RequestArgs[0] . 'controller.php');
                 $ControllerFileName = CombinePaths($PathParts);
                 $ControllerPath = Gdn_FileSystem::FindByMapping('controller', PATH_APPLICATIONS, $ApplicationFolders, $ControllerFileName);
                 if (!$ControllerPath || !file_exists($ControllerPath)) {
                     $Sender->EventArguments['RequestUri'] =& $RequestUri;
                     $Sender->FireEvent('BeforeGetRoute');
                     $NewRequest = CandyModel::GetRouteRequestUri($RequestUri);
                     if ($NewRequest) {
                         $Request->WithURI($NewRequest);
                     }
                 }
             }
         }
     }
 }