fixed some bugs
This commit is contained in:
		
							parent
							
								
									ea40fc8e38
								
							
						
					
					
						commit
						713a44ad98
					
				@ -34,7 +34,12 @@ class Router {
 | 
			
		||||
    private function setRouteFile() {
 | 
			
		||||
        foreach ($this->routes as $key => $value) {
 | 
			
		||||
            if ( $this->path == $key) {
 | 
			
		||||
                $this->controllerPath = BASEPATH . '/App/controllers/' . $value['file'] . '.php';
 | 
			
		||||
                $theFile = BASEPATH . '/App/controllers/' . $value['file'] . '.php';
 | 
			
		||||
 | 
			
		||||
                //check if the file exists
 | 
			
		||||
                if (file_exists($theFile)) {
 | 
			
		||||
                    $this->controllerPath = $theFile;
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@ -2,10 +2,20 @@
 | 
			
		||||
require_once(BASEPATH . '/vendor/autoload.php');
 | 
			
		||||
 | 
			
		||||
//Twig
 | 
			
		||||
function view($name = '', $data = [] ) {
 | 
			
		||||
    $loader = new Twig\Loader\FilesystemLoader(BASEPATH . '/App/views/');
 | 
			
		||||
    $loader->addPath(BASEPATH . '/vendor/4lt/novaconium/twig', 'novaconium');
 | 
			
		||||
    $loader->addPath(BASEPATH . '/App/templates', 'override');
 | 
			
		||||
    $twig = new Twig\Environment($loader);
 | 
			
		||||
    //check if file exists
 | 
			
		||||
    if (file_exists(BASEPATH . '/App/views/' . $name . '.html.twig')) {
 | 
			
		||||
        echo $twig->render("$name" . '.html.twig', $data);
 | 
			
		||||
        return true;
 | 
			
		||||
    } else {
 | 
			
		||||
        echo "Error: Twig Template ($name) Not Found.";
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Load a controller
 | 
			
		||||
require_once('Router.php');
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user