Created error model and view
parent
4d5cf33d32
commit
5b91fadef2
@ -0,0 +1,22 @@
|
||||
<?php declare (strict_types = 1);
|
||||
|
||||
/**
|
||||
* Model for error messages
|
||||
*/
|
||||
class ErrorModel
|
||||
{
|
||||
/** @var string $message text to display */
|
||||
public $message;
|
||||
|
||||
/**
|
||||
* Construct ErrorModel
|
||||
*
|
||||
* @param string $message text to display
|
||||
* @param string $template path to the template file
|
||||
*/
|
||||
public function __construct($template, $message)
|
||||
{
|
||||
$this->message = $message;
|
||||
$this->template = $template;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php declare (strict_types = 1);
|
||||
|
||||
/**
|
||||
* View for rendering error messages
|
||||
*/
|
||||
class ErrorView
|
||||
{
|
||||
/**
|
||||
* @var ErrorModel $model
|
||||
*/
|
||||
private $model;
|
||||
|
||||
/**
|
||||
* Constructor for Error View
|
||||
* @param ErrorModel $model
|
||||
*/
|
||||
public function __construct($model)
|
||||
{
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render SVG Output
|
||||
* @return string
|
||||
*/
|
||||
public function output()
|
||||
{
|
||||
// import variables into symbol table
|
||||
extract(["message" => $this->model->lines]);
|
||||
// render SVG with output buffering
|
||||
ob_start();
|
||||
require_once $this->model->template;
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
// return rendered output
|
||||
return $output;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue