Example #1
0
     ini_set('log_errors', 'On');
     ini_set('error_log', ROOT . DS . 'tmp' . DS . 'logs' . DS . 'error.log');
 }
 //Load the defined routes file into array
 try {
     //check of the routes configuration file exists
     if (!file_exists(__DIR__ . '/../application/routes.php')) {
         throw new Exceptions\BaseException("The defined routes file cannot be found! Please restore if you deleted");
     }
     //get the defined routes
     $routes = (include __DIR__ . '/../application/routes.php');
 } 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');
Example #2
0
<?php

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 Exceptions\BaseException("The defined routes file cannot be found! Please restore if you deleted");
        }
        //get the defined routes
        $routes = (include __DIR__ . '/../application/routes.php');
    } 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']);