Skip to content

Commit

Permalink
Added the basic php renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljennings committed Apr 12, 2015
1 parent 4086326 commit f0433fb
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@
* Coreplex\Notifier\Session\Native
* Coreplex\Notifier\Session\IlluminateSession
*/
'session' => 'Coreplex\\Notifier\\Session\\Native',
'session' => 'Coreplex\\Notifier\\Session\\IlluminateSession',

];
59 changes: 59 additions & 0 deletions src/Notifier/Renderers/Basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php namespace Coreplex\Notifier\Renderers;

use Coreplex\Notifier\Contracts\Renderer;

class Basic implements Renderer {

/**
* The template to be rendered.
*
* @var string
*/
protected $template;

public function __construct()
{}

/**
* Render the notifications.
*
* @param array $data
* @return string
*/
public function render(array $data)
{
$template = $this->template;

if ( ! file_exists($template)) {
dd('template does not exist');
}

// Extract the passed variables
extract($data);

// include the template
include ($template);

// Get the content
$content = ob_get_contents();
// Clear the output buffer
ob_end_clean();

// Return the content
return $content;
}

/**
* Set the template to be used by the renderer.
*
* @param $template
* @return $this
*/
public function setTemplate($template)
{
$this->template = $template;

return $this;
}

}

0 comments on commit f0433fb

Please sign in to comment.