value, $this->getDefaultSettings()); if (!\is_array($settings)) { $settings = $this->getDefaultSettings(); } $settings = array_merge($this->getDefaultSettings(), $settings); // Every switch filled in, the type chips' from Sort where it was never // saved — the same answer the portal is given. $settings['portalFilters'] = GeneralSettings::portalFilters($settings); // The card's copy is the plugin's, not stored: resolve it so the admin // preview shows exactly what the portal will. $settings['promo'] = GeneralSettings::promo($settings); return Response::success($settings); } public function update(UpdateGeneralSettingsRequest $request) { $data = $request->toSettingsData(); $added = Config::addOption(GeneralSettings::OPTION_NAME->value, $data); if (!$added) { Config::updateOption(GeneralSettings::OPTION_NAME->value, $data); } return Response::success(array_merge($data, ['promo' => GeneralSettings::promo($data)])); } private function getDefaultSettings(): array { return [ 'communityTitle' => '', 'logoLight' => '', 'logoPermalinkMode' => 'default', 'logoPermalinkCustom' => '', 'portalAccess' => 'everyone', // Portal topic-list filter controls. Visible unless an admin turns // one off, so installs that predate this setting keep their toolbar. 'portalFilters' => [ 'sort' => true, 'tags' => true, 'types' => true, ], // The Bit Apps credit card at the foot of the portal sidebar. Off // until an admin asks for it: it links off the owner's own public // pages. Its copy is fixed — see GeneralSettings::promo(). 'promo' => [ 'enabled' => false, ], // The Following row in the portal sidebar. Off until an admin asks for it. 'sidebarFollowing' => false, ]; } }