mirror of
https://github.com/flarum/core.git
synced 2025-10-11 23:14:29 +02:00
Starting with version 5.9, the global funtions will be deprecated. * https://laravel-news.com/laravel-5-8-deprecates-string-and-array-helpers * https://github.com/laravel/framework/pull/26898
45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?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\Extension;
|
|
|
|
use Flarum\Extension\Event\Disabling;
|
|
use Flarum\Http\Exception\ForbiddenException;
|
|
use Flarum\Settings\SettingsRepositoryInterface;
|
|
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 ForbiddenException('You cannot disable the default language pack!');
|
|
}
|
|
}
|
|
}
|