1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 15:34:26 +02:00

Early returns

This commit is contained in:
Franz Liedke
2018-12-13 21:58:00 +01:00
parent b58380e224
commit 4b00f7996b
2 changed files with 50 additions and 43 deletions

View File

@@ -42,12 +42,15 @@ class DefaultLanguagePackGuard
*/
public function whenExtensionWillBeDisabled(Disabling $event)
{
if (in_array('flarum-locale', $event->extension->extra)) {
$defaultLocale = $this->settings->get('default_locale');
$locale = array_get($event->extension->extra, 'flarum-locale.code');
if ($locale === $defaultLocale) {
throw new ForbiddenException('You cannot disable the default language pack!');
}
if (! in_array('flarum-locale', $event->extension->extra)) {
return;
}
$defaultLocale = $this->settings->get('default_locale');
$locale = array_get($event->extension->extra, 'flarum-locale.code');
if ($locale === $defaultLocale) {
throw new ForbiddenException('You cannot disable the default language pack!');
}
}
}