1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 23:44:27 +02:00
Files
php-flarum/src/Extension/DefaultLanguagePackGuard.php
Franz Liedke d492579638 Apply fixes from StyleCI
[ci skip] [skip ci]
2019-11-28 00:16:50 +00:00

43 lines
1.0 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Extension;
use Flarum\Extension\Event\Disabling;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\Exception\PermissionDeniedException;
use Illuminate\Support\Arr;
class DefaultLanguagePackGuard
{
/**
* @var SettingsRepositoryInterface
*/
protected $settings;
public function __construct(SettingsRepositoryInterface $settings)
{
$this->settings = $settings;
}
public function handle(Disabling $event)
{
if (! in_array('flarum-locale', $event->extension->extra)) {
return;
}
$defaultLocale = $this->settings->get('default_locale');
$locale = Arr::get($event->extension->extra, 'flarum-locale.code');
if ($locale === $defaultLocale) {
throw new PermissionDeniedException('You cannot disable the default language pack!');
}
}
}