예제 #1
0
파일: start.php 프로젝트: ericobi797/gliver
 } catch (Exceptions\BaseException $error) {
     $error->show();
     return;
 }
 $routeObj = new Drivers\Routes\Implementation();
 //there is a defined route
 if ($routeObj->dispatch($url, $routes)) {
     //get the controller name
     ($controller = $routeObj->getController()) || ($controller = 'Home');
     //get the action name
     ($action = $routeObj->getMethod()) || ($action = 'Index');
     //get parameters
     $parameters = $routeObj->getParameters();
 } else {
     //create an instance of the url parser
     $urlObj = new Drivers\Utilities\UrlParser($url);
     //get the controller name
     ($controller = $urlObj->getController()) || ($controller = 'Home');
     //get the action name
     ($action = $urlObj->getMethod()) || ($action = 'Index');
     //get parameters
     $parameters = $urlObj->getParameters();
 }
 //check if this class and method exists
 try {
     //get the namespaced controller class
     $controller = 'Controllers\\' . ucwords($controller) . 'Controller';
     if (!class_exists($controller)) {
         throw new Exceptions\BaseException("The class " . $controller . ' is undefined');
     }
     if (!(int) method_exists($controller, $action)) {
예제 #2
0
return function () use($config) {
    //Load the defined routes file into array
    try {
        //check of the routes configuration file exists
        if (!file_exists(__DIR__ . '/../application/routes.php')) {
            throw new Drivers\Routes\RouteException("Drivers\\Routes\\RouteException : The defined routes.php file cannot be found! Please restore if you deleted");
        }
        //get the defined routes
        $definedRoutes = (include __DIR__ . '/../application/routes.php');
    } catch (Drivers\Routes\RouteException $ExceptionObjectInstance) {
        //display the error message to the browser
        $ExceptionObjectInstance->errorShow();
    }
    //create an instance of the UrlParser Class,
    $UrlParserObjectInstance = new Drivers\Utilities\UrlParser(Drivers\Registry::getUrl(), Drivers\Registry::getConfig()['url_component_separator']);
    //and set controller, method and request parameter
    $UrlParserObjectInstance->setController()->setMethod()->setParameters();
    //create an instance of the route parser class
    $RouteParserObject = new Drivers\Routes\RouteParser(Drivers\Registry::getUrl(), $definedRoutes, $UrlParserObjectInstance);
    //check if there is infered controller from url string
    if ($UrlParserObjectInstance->getController() !== null) {
        //check if there is a defined route matched
        if ($RouteParserObject->matchRoute()) {
            //if there is a defined route, set the controller, method and parameter properties
            $RouteParserObject->setController()->setMethod()->setParameters();
            //set the value of the controller
            $controller = $RouteParserObject->getController();
            //set the value of the method
            ($action = $RouteParserObject->getMethod()) || ($action = $config['default']['action']);
        } else {
예제 #3
0
파일: start.php 프로젝트: joycekenya/gliver
 } catch (Exceptions\BaseException $error) {
     $error->show();
     return;
 }
 $routeObj = new Drivers\Routes\Implementation();
 //there is a defined route
 if ($routeObj->dispatch(Drivers\Registry::getUrl(), $routes)) {
     //get the controller name
     ($controller = $routeObj->getController()) || ($controller = $config['default']['controller']);
     //get the action name
     ($action = $routeObj->getMethod()) || ($action = $config['default']['action']);
     //get parameters
     $parameters = $routeObj->getParameters();
 } else {
     //create an instance of the url parser
     $urlObj = new Drivers\Utilities\UrlParser(Drivers\Registry::getUrl());
     //get the controller name
     ($controller = $urlObj->getController()) || ($controller = $config['default']['controller']);
     //get the action name
     ($action = $urlObj->getMethod()) || ($action = $config['default']['action']);
     //get parameters
     $parameters = $urlObj->getParameters();
 }
 //check if this class and method exists
 try {
     //get the namespaced controller class
     $controller = 'Controllers\\' . ucwords($controller) . 'Controller';
     if (!class_exists($controller)) {
         throw new Exceptions\BaseException("The class " . $controller . ' is undefined');
     }
     if (!(int) method_exists($controller, $action)) {