mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 11:00:40 +08:00
SuiteCRM 8 initial commit
This commit is contained in:
commit
c895877b7e
547 changed files with 40449 additions and 0 deletions
39
core/base/Module/View/Handler.php
Normal file
39
core/base/Module/View/Handler.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace SuiteCRM\Core\Base\Module\View;
|
||||
|
||||
use \stdClass;
|
||||
|
||||
/**
|
||||
* Class Handler
|
||||
* @package SuiteCRM\Core\Base\Module\View
|
||||
*/
|
||||
class Handler
|
||||
{
|
||||
|
||||
/**
|
||||
* Render the view file and pass it to the templates
|
||||
*
|
||||
* @param string $filename The view files name
|
||||
* @param array $params Params to pass to view file
|
||||
* @param string $template
|
||||
* @return mixed
|
||||
*/
|
||||
public function render($filename, $params = [], $template = 'default.json.php')
|
||||
{
|
||||
// Allow the view param to work with and with the .php
|
||||
$filename = (strpos($filename, '.php') !== false) ? $filename : $filename . '.php';
|
||||
|
||||
$view = new stdClass();
|
||||
|
||||
// Extract the parameters
|
||||
extract($params);
|
||||
|
||||
if (file_exists(__DIR__ . '/template/default.json.php')) {
|
||||
require __DIR__ . '/template/default.json.php';
|
||||
} else {
|
||||
echo $body;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue