url = explode('?', $_SERVER['REQUEST_URI'], 2); $this->customPath = $customPath; $this->pages = $pages; $this->pageError = $pageError; $this->status = false; } public function render() { foreach ( $this->pages as $key => $page ) { if( $this->url[0] === $this->customPath.$page['url'] ) { if( isset( $page['load'] ) ) { if( file_exists( $page['load'] ) ) { require $page['load']; } else { echo 'Error loading add-ons'; } } if(isset($page['view']) ) { if( file_exists( $page['view'] ) ) { require $page['view']; } else { echo 'View loading error!'; } } $this->status = true; break; } } if( !$this->status ) { require $this->pageError; } } public static function getInstance($config) { $pages = $config['views']; $pageError = $config['pageError']; $customPath = $config['customPath']; $instance = new self($pages,$pageError,$customPath); return $instance; } } ?>