mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-30 11:59:31 +01:00
Apply fixes from StyleCI
This commit is contained in:
parent
6fb043e109
commit
2b8580727f
app/Bus/Handlers/Commands/Incident
config
@ -23,12 +23,9 @@ use CachetHQ\Cachet\Models\Meta;
|
||||
use CachetHQ\Cachet\Services\Dates\DateFactory;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
|
||||
use Twig\Environment as Twig_Environment;
|
||||
use Twig\Loader\ArrayLoader as Twig_Loader_Array;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is the create incident command handler.
|
||||
*
|
||||
@ -67,7 +64,7 @@ class CreateIncidentCommandHandler
|
||||
$this->auth = $auth;
|
||||
$this->dates = $dates;
|
||||
|
||||
$this->twigConfig = config("cachet.twig");
|
||||
$this->twigConfig = config('cachet.twig');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,31 +135,34 @@ class CreateIncidentCommandHandler
|
||||
return $incident;
|
||||
}
|
||||
|
||||
protected function sandboxedTwigTemplateData(String $templateData) {
|
||||
|
||||
protected function sandboxedTwigTemplateData(string $templateData)
|
||||
{
|
||||
if (!$templateData) {
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
$policy = new \Twig\Sandbox\SecurityPolicy($this->twigConfig["tags"],
|
||||
$this->twigConfig["filters"],
|
||||
$this->twigConfig["methods"],
|
||||
$this->twigConfig["props"],
|
||||
$this->twigConfig["functions"]);
|
||||
$policy = new \Twig\Sandbox\SecurityPolicy(
|
||||
$this->twigConfig['tags'],
|
||||
$this->twigConfig['filters'],
|
||||
$this->twigConfig['methods'],
|
||||
$this->twigConfig['props'],
|
||||
$this->twigConfig['functions']
|
||||
);
|
||||
|
||||
$sandbox = new \Twig\Extension\SandboxExtension($policy);
|
||||
|
||||
$templateBasicLoader = new Twig_Loader_Array([
|
||||
'firstStageLoader' => $templateData
|
||||
'firstStageLoader' => $templateData,
|
||||
]);
|
||||
|
||||
$sandBoxBasicLoader = new Twig_Loader_Array([
|
||||
'secondStageLoader' => '{% sandbox %}{% include "firstStageLoader" %} {% endsandbox %}'
|
||||
'secondStageLoader' => '{% sandbox %}{% include "firstStageLoader" %} {% endsandbox %}',
|
||||
]);
|
||||
|
||||
$hardenedLoader = new \Twig\Loader\ChainLoader([$templateBasicLoader, $sandBoxBasicLoader]);
|
||||
$twig = new Twig_Environment($hardenedLoader);
|
||||
$twig->addExtension($sandbox);
|
||||
|
||||
return $twig;
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ class CreateIncidentCommandHandler
|
||||
'component_status' => $command->component_status,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
return $template->render('secondStageLoader', $vars);
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,6 @@ use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\IncidentTemplate;
|
||||
use CachetHQ\Cachet\Services\Dates\DateFactory;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Twig\Environment as Twig_Environment;
|
||||
use Twig\Loader\ArrayLoader as Twig_Loader_Array;
|
||||
|
||||
/**
|
||||
* This is the update incident command handler.
|
||||
@ -65,7 +63,7 @@ class UpdateIncidentCommandHandler
|
||||
$this->auth = $auth;
|
||||
$this->dates = $dates;
|
||||
|
||||
$this->twigConfig = $twigConfig = config("cachet.twig");
|
||||
$this->twigConfig = $twigConfig = config('cachet.twig');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -147,25 +145,29 @@ class UpdateIncidentCommandHandler
|
||||
});
|
||||
}
|
||||
|
||||
protected function sandboxedTwigTemplateData(String $templateData) {
|
||||
$policy = new \Twig\Sandbox\SecurityPolicy($this->twigConfig["tags"],
|
||||
$this->twigConfig["filters"],
|
||||
$this->twigConfig["methods"],
|
||||
$this->twigConfig["props"],
|
||||
$this->twigConfig["functions"]);
|
||||
protected function sandboxedTwigTemplateData(string $templateData)
|
||||
{
|
||||
$policy = new \Twig\Sandbox\SecurityPolicy(
|
||||
$this->twigConfig['tags'],
|
||||
$this->twigConfig['filters'],
|
||||
$this->twigConfig['methods'],
|
||||
$this->twigConfig['props'],
|
||||
$this->twigConfig['functions']
|
||||
);
|
||||
$sandbox = new \Twig\Extension\SandboxExtension($policy);
|
||||
|
||||
$templateBasicLoader = new \Twig\Loader\ArrayLoader([
|
||||
'firstStageLoader' => $templateData
|
||||
'firstStageLoader' => $templateData,
|
||||
]);
|
||||
|
||||
$sandBoxBasicLoader = new \Twig\Loader\ArrayLoader([
|
||||
'secondStageLoader' => '{% sandbox %}{% include "firstStageLoader" %} {% endsandbox %}'
|
||||
'secondStageLoader' => '{% sandbox %}{% include "firstStageLoader" %} {% endsandbox %}',
|
||||
]);
|
||||
|
||||
$hardenedLoader = new \Twig\Loader\ChainLoader([$templateBasicLoader, $sandBoxBasicLoader]);
|
||||
$twig = new \Twig\Environment($hardenedLoader);
|
||||
$twig->addExtension($sandbox);
|
||||
|
||||
return $twig;
|
||||
}
|
||||
|
||||
@ -194,7 +196,7 @@ class UpdateIncidentCommandHandler
|
||||
'component_status' => $command->component_status,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
return $template->render('secondStageLoader', $vars);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ return [
|
||||
|
||||
'beacon' => env('CACHET_BEACON', true),
|
||||
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Templates configurations
|
||||
@ -58,10 +57,10 @@ return [
|
||||
|
|
||||
*/
|
||||
'twig' => [
|
||||
'methods' => [],
|
||||
'methods' => [],
|
||||
'functions' => [],
|
||||
'filters' => ['escape'],
|
||||
'tags' => ['if'],
|
||||
'props' => [],
|
||||
]
|
||||
'filters' => ['escape'],
|
||||
'tags' => ['if'],
|
||||
'props' => [],
|
||||
],
|
||||
];
|
||||
|
Loading…
x
Reference in New Issue
Block a user