/** * Get the forum, ready to be serialized and assigned to the JsonApi * response. * * @param JsonApiRequest $request * @param Document $document * @return \Flarum\Core\Forum */ protected function data(JsonApiRequest $request, Document $document) { if (!$request->actor->isAdmin()) { throw new PermissionDeniedException(); } $config = $request->get('data.attributes.config'); if (is_array($config)) { foreach ($config as $k => $v) { $this->settings->set($k, $v); } } return app('flarum.forum'); }
/** * {@inheritdoc} */ public function handle(Request $request, array $routeParams = []) { if (!$request->actor->isAdmin()) { throw new PermissionDeniedException(); } $config = $request->get('config', []); // TODO: throw HTTP status 400 or 422 if (!is_array($config)) { throw new Exception(); } foreach ($config as $k => $v) { $this->settings->set($k, $v); if (strpos($k, 'theme_') === 0 || $k === 'custom_less') { $forum = app('Flarum\\Forum\\Actions\\ClientAction'); $forum->flushAssets(); $admin = app('Flarum\\Admin\\Actions\\ClientAction'); $admin->flushAssets(); } } return new EmptyResponse(204); }
public function it_passes_new_data_to_inner(SettingsRepository $inner) { $this->set('a', 1); $inner->set('a', 1)->shouldHaveBeenCalled(); }