Skip to content

Instantly share code, notes, and snippets.

@estefanionsantos
Created April 3, 2022 16:36
Show Gist options
  • Save estefanionsantos/20c2f5c805b34c69461d263543f78e6c to your computer and use it in GitHub Desktop.
Save estefanionsantos/20c2f5c805b34c69461d263543f78e6c to your computer and use it in GitHub Desktop.
ViewHelper 01
<?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