I have to seem problems grasping the concept of Views in MVC, they are, according to what I\'ve read, the layer that manages the presentation in the aplication, but many of
class View {
protected $data;
protected $path;
protected static function getDefaultViewPath() {
$router = App::getRouter();
if(!$router){
return false;
}
$controller_path = $router->getController();
$method_path = ($router->getMethodPrefix() !== "" ? $router->getMethodPrefix() . '_' : '') . $router->getAction();
return ROOT . "/views/" . $controller_path . "/" . $method_path . ".phtml";
}
public function __construct($data = array(), $path = null) {
if(!$path){
//default
$path = $this->getDefaultViewPath();
}
if(!file_exists($path)){
throw new Exception("Error view file!");
}
$this->data = $data;
$this->path = $path;
}
public function render(){
$data = $this->data;
ob_start();
include ($this->path);
$content = ob_get_clean();
return $content;
}
}