1
0
mirror of https://github.com/flarum/core.git synced 2025-08-04 15:37:51 +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)) {
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!');
}
}
}
}

View File

@@ -69,7 +69,10 @@ class ValidateCustomLess
*/
public function whenSettingsSaving(Saving $event)
{
if (isset($event->settings['custom_less'])) {
if (! isset($event->settings['custom_less'])) {
return;
}
// We haven't saved the settings yet, but we want to trial a full
// recompile of the CSS to see if this custom LESS will break
// anything. In order to do that, we will temporarily override the
@@ -102,19 +105,20 @@ class ValidateCustomLess
$this->assets->setAssetsDir($assetsDir);
$this->container->instance(SettingsRepositoryInterface::class, $settings);
}
}
/**
* @param Saved $event
*/
public function whenSettingsSaved(Saved $event)
{
if (isset($event->settings['custom_less'])) {
if (! isset($event->settings['custom_less'])) {
return;
}
$this->assets->makeCss()->flush();
foreach ($this->locales->getLocales() as $locale => $name) {
$this->assets->makeLocaleCss($locale)->flush();
}
}
}
}