mirror of
https://github.com/flarum/core.git
synced 2025-08-04 15:37:51 +02:00
Early returns
This commit is contained in:
@@ -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!');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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,14 +105,16 @@ 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) {
|
||||
@@ -117,4 +122,3 @@ class ValidateCustomLess
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user