1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 07:24:27 +02:00

Move ExtensionValidator class to Flarum\Extension namespace

This commit is contained in:
Franz Liedke
2017-06-24 14:27:54 +02:00
parent 8a16c1ecc8
commit e71deed8d5
2 changed files with 3 additions and 3 deletions

View File

@@ -109,7 +109,7 @@ class CoreServiceProvider extends AbstractServiceProvider
$events->subscribe('Flarum\Core\Listener\SelfDemotionGuard');
$events->subscribe('Flarum\Discussion\DiscussionMetadataUpdater');
$events->subscribe('Flarum\User\UserMetadataUpdater');
$events->subscribe('Flarum\Core\Listener\ExtensionValidator');
$events->subscribe('Flarum\Extension\DefaultLanguagePackGuard');
$events->subscribe('Flarum\User\EmailConfirmationMailer');
$events->subscribe('Flarum\Discussion\DiscussionRenamedNotifier');

View File

@@ -1,42 +0,0 @@
<?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\Core\Listener;
use Flarum\Event\ExtensionWillBeDisabled;
use Flarum\Http\Exception\ForbiddenException;
use Illuminate\Contracts\Events\Dispatcher;
class ExtensionValidator
{
/**
* @param Dispatcher $events
*/
public function subscribe(Dispatcher $events)
{
$events->listen(ExtensionWillBeDisabled::class, [$this, 'whenExtensionWillBeDisabled']);
}
/**
* @param ExtensionWillBeDisabled $event
* @throws ForbiddenException
*/
public function whenExtensionWillBeDisabled(ExtensionWillBeDisabled $event)
{
if (in_array('flarum-locale', $event->extension->extra)) {
$default_locale = $this->app->make('flarum.settings')->get('default_locale');
$locale = array_get($event->extension->extra, 'flarum-locale.code');
if ($locale === $default_locale) {
throw new ForbiddenException('You cannot disable the default language pack!');
}
}
}
}