1
0
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:
Daniel Klabbers
2017-12-15 08:10:32 +01:00
parent f65e4dcba3
commit 2aba61668c
14 changed files with 27 additions and 49 deletions

View File

@@ -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;

View 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(),
]);
}
}
}
}