mirror of
https://github.com/flarum/core.git
synced 2025-10-12 15:34:26 +02:00
- satisfying styleci
- cleared the merge conflict in the phpdoc - changed some string class names to use ::class
This commit is contained in:
@@ -11,14 +11,11 @@
|
||||
|
||||
namespace Flarum\Admin;
|
||||
|
||||
use Flarum\Admin\Listener\CheckCustomLessFormat;
|
||||
use Flarum\Admin\Middleware\RequireAdministrateAbility;
|
||||
use Flarum\Event\ConfigureMiddleware;
|
||||
use Flarum\Extension\Event\Disabled;
|
||||
use Flarum\Extension\Event\Enabled;
|
||||
use Flarum\Core\Listener\CheckCustomLessFormat;
|
||||
use Flarum\Event\ExtensionWasDisabled;
|
||||
use Flarum\Event\ExtensionWasEnabled;
|
||||
use Flarum\Event\SettingWasSet;
|
||||
use Flarum\Foundation\AbstractServiceProvider;
|
||||
use Flarum\Http\Middleware\AuthenticateWithSession;
|
||||
use Flarum\Http\Middleware\DispatchRoute;
|
||||
|
43
src/Admin/Listener/CheckCustomLessFormat.php
Normal file
43
src/Admin/Listener/CheckCustomLessFormat.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Flarum.
|
||||
*
|
||||
* (c) Toby Zerner <toby.zerner@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flarum\Admin\Listener;
|
||||
|
||||
use Flarum\Foundation\ValidationException;
|
||||
use Flarum\Settings\Event\Serializing;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Less_Exception_Parser;
|
||||
use Less_Parser;
|
||||
|
||||
class CheckCustomLessFormat
|
||||
{
|
||||
public function subscribe(Dispatcher $events)
|
||||
{
|
||||
$events->listen(Serializing::class, [$this, 'check']);
|
||||
}
|
||||
|
||||
public function check(Serializing $event)
|
||||
{
|
||||
if ($event->key === 'custom_less') {
|
||||
$parser = new Less_Parser();
|
||||
|
||||
try {
|
||||
// Check the custom less format before saving
|
||||
// Variables names are not checked, we would have to set them and call getCss() to check them
|
||||
$parser->parse($event->value);
|
||||
} catch (Less_Exception_Parser $e) {
|
||||
throw new ValidationException([
|
||||
'custom_less' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user