-
Notifications
You must be signed in to change notification settings - Fork 0
/
Public.php
executable file
·41 lines (33 loc) · 1.29 KB
/
Public.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
// Public functions
use ComponentLibrary\Init;
if (!function_exists('disturbance_render_blade_view')) {
function disturbance_render_blade_view($view, $data = [], $compress = true)
{
$viewPath = APIALARMINTEGRATION_MODULE_VIEW_PATH;
$componentLibrary = new Init([]);
$bladeEngine = $componentLibrary->getEngine();
$data = array_merge( $data, array('errorMessage' => false) );
try {
$markup = $bladeEngine->makeView( $view, $data, [], $viewPath )->render();
} catch (\Throwable $e) {
$markup .= '<pre style="border: 3px solid #f00; padding: 10px;">';
$markup .= '<strong>' . $e->getMessage() . '</strong>';
$markup .= '<hr style="background: #000; outline: none; border:none; display: block; height: 1px;"/>';
$markup .= $e->getTraceAsString();
$markup .= '</pre>';
}
if ($compress == true) {
$replacements = array(
["~<!--(.*?)-->~s", ""],
["/\r|\n/", ""],
["!\s+!", " "]
);
foreach ($replacements as $replacement) {
$markup = preg_replace($replacement[0], $replacement[1], $markup);
}
return $markup;
}
return $markup;
}
}