mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-22 13:24:24 +02:00
Introduce and utilize class Icinga\Util\LessParser
This commit is contained in:
parent
36003df087
commit
f4a8599193
@ -22,6 +22,7 @@
|
|||||||
<exclude-pattern>library/Icinga/Application/LegacyWeb.php</exclude-pattern>
|
<exclude-pattern>library/Icinga/Application/LegacyWeb.php</exclude-pattern>
|
||||||
<exclude-pattern>library/Icinga/Application/Web.php</exclude-pattern>
|
<exclude-pattern>library/Icinga/Application/Web.php</exclude-pattern>
|
||||||
<exclude-pattern>library/Icinga/File/Pdf.php</exclude-pattern>
|
<exclude-pattern>library/Icinga/File/Pdf.php</exclude-pattern>
|
||||||
|
<exclude-pattern>library/Icinga/Util/LessParser.php</exclude-pattern>
|
||||||
<exclude-pattern>modules/doc/library/Doc/Renderer/DocSectionRenderer.php</exclude-pattern>
|
<exclude-pattern>modules/doc/library/Doc/Renderer/DocSectionRenderer.php</exclude-pattern>
|
||||||
<exclude-pattern>modules/monitoring/library/Monitoring/Plugin.php</exclude-pattern>
|
<exclude-pattern>modules/monitoring/library/Monitoring/Plugin.php</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
|
38
library/Icinga/Util/LessParser.php
Normal file
38
library/Icinga/Util/LessParser.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
/* Icinga Web 2 | (c) 2021 Icinga GmbH | GPLv2+ */
|
||||||
|
|
||||||
|
namespace Icinga\Util;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use lessc;
|
||||||
|
use Icinga\Application\Logger;
|
||||||
|
|
||||||
|
require_once 'lessphp/lessc.inc.php';
|
||||||
|
|
||||||
|
class LessParser extends lessc
|
||||||
|
{
|
||||||
|
protected function get($name)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return parent::get($name);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
Logger::error($e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['string', '', []];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function compileProp($prop, $block, $out)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
parent::compileProp($prop, $block, $out);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if (strpos($e->getMessage(), 'is undefined:') === false) {
|
||||||
|
// We silence mixin errors only
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::error($e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@
|
|||||||
namespace Icinga\Web;
|
namespace Icinga\Web;
|
||||||
|
|
||||||
use Icinga\Application\Logger;
|
use Icinga\Application\Logger;
|
||||||
use lessc;
|
use Icinga\Util\LessParser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile LESS into CSS
|
* Compile LESS into CSS
|
||||||
@ -16,7 +16,7 @@ class LessCompiler
|
|||||||
/**
|
/**
|
||||||
* lessphp compiler
|
* lessphp compiler
|
||||||
*
|
*
|
||||||
* @var lessc
|
* @var LessParser
|
||||||
*/
|
*/
|
||||||
protected $lessc;
|
protected $lessc;
|
||||||
|
|
||||||
@ -60,8 +60,7 @@ class LessCompiler
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
require_once 'lessphp/lessc.inc.php';
|
$this->lessc = new LessParser();
|
||||||
$this->lessc = new lessc();
|
|
||||||
// Discourage usage of import because we're caching based on an explicit list of LESS files to compile
|
// Discourage usage of import because we're caching based on an explicit list of LESS files to compile
|
||||||
$this->lessc->importDisabled = true;
|
$this->lessc->importDisabled = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user