mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
Fix php style
This commit is contained in:
parent
461bd9c98d
commit
b8bd067dc7
59 changed files with 2307 additions and 1868 deletions
|
@ -13,16 +13,16 @@ namespace controllers\internals;
|
|||
|
||||
/**
|
||||
* Templating questions relative class
|
||||
* Not a standard controller as it's not linked to a model in any way
|
||||
* Not a standard controller as it's not linked to a model in any way.
|
||||
*/
|
||||
class Templating
|
||||
{
|
||||
/**
|
||||
* Twig environment
|
||||
* Twig environment.
|
||||
*/
|
||||
private $sandbox;
|
||||
|
||||
public function __construct ()
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$tags = [
|
||||
'if',
|
||||
|
@ -45,23 +45,24 @@ namespace controllers\internals;
|
|||
$properties = [];
|
||||
$functions = [
|
||||
'date', 'max', 'min', 'random',
|
||||
'range',
|
||||
'range',
|
||||
];
|
||||
|
||||
$policy = new \Twig\Sandbox\SecurityPolicy($tags, $filters, $methods, $properties, $functions);
|
||||
$this->sandbox = new \Twig\Extension\SandboxExtension($policy, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Render a string as a twig template
|
||||
* Render a string as a twig template.
|
||||
*
|
||||
* @param string $template : Template string
|
||||
* @param array $datas : Datas to pass to the template
|
||||
* @param array $datas : Datas to pass to the template
|
||||
*
|
||||
* @return array : keys, success, error, result
|
||||
*/
|
||||
public function render (string $template, array $datas = [])
|
||||
public function render(string $template, array $datas = [])
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
$loader = new \Twig\Loader\ArrayLoader([
|
||||
'template' => $template,
|
||||
|
@ -69,7 +70,7 @@ namespace controllers\internals;
|
|||
|
||||
$twig = new \Twig\Environment($loader);
|
||||
$result = $twig->render('template', $datas);
|
||||
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'result' => $result,
|
||||
|
@ -83,5 +84,4 @@ namespace controllers\internals;
|
|||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue