Created
April 3, 2022 16:36
-
-
Save estefanionsantos/20c2f5c805b34c69461d263543f78e6c to your computer and use it in GitHub Desktop.
ViewHelper 01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Helper; | |
use Rubricate\Resource\DirectoryPathResource; | |
use Rubricate\Resource\FileResource; | |
use Rubricate\Resource\BufferResource; | |
class ViewHelper | |
{ | |
private $path = 'src/view/'; | |
public function __construct($path = null) | |
{ | |
$dir = (is_null($path))? $this->path: $path; | |
$path = new DirectoryPathResource($dir); | |
$file = new FileResource($path); | |
$buffer = new BufferResource($file); | |
$this->file = $file; | |
$this->buffer = $buffer; | |
} | |
public function render($view, $data = array()) | |
{ | |
$this->file->incorporate($view, $data); | |
} | |
public function str($view, $data = array()) | |
{ | |
return $this->buffer->incorporate($view, $data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment