-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4086326
commit f0433fb
Showing
2 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
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; | ||
} | ||
|
||
} |