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/Web.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/monitoring/library/Monitoring/Plugin.php</exclude-pattern>
|
||||
</rule>
|
||||
|
|
|
@ -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;
|
||||
|
||||
use Icinga\Application\Logger;
|
||||
use lessc;
|
||||
use Icinga\Util\LessParser;
|
||||
|
||||
/**
|
||||
* Compile LESS into CSS
|
||||
|
@ -16,7 +16,7 @@ class LessCompiler
|
|||
/**
|
||||
* lessphp compiler
|
||||
*
|
||||
* @var lessc
|
||||
* @var LessParser
|
||||
*/
|
||||
protected $lessc;
|
||||
|
||||
|
@ -60,8 +60,7 @@ class LessCompiler
|
|||
*/
|
||||
public function __construct()
|
||||
{
|
||||
require_once 'lessphp/lessc.inc.php';
|
||||
$this->lessc = new lessc();
|
||||
$this->lessc = new LessParser();
|
||||
// Discourage usage of import because we're caching based on an explicit list of LESS files to compile
|
||||
$this->lessc->importDisabled = true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue