wikiService = $wikiService; } /** * @throws BindingResolutionException */ #[RequiresPermission(WikiPermissions::VIEW)] public function get($params): Response { $wiki = app()->make(Wiki::class); if (isset($_GET['id'])) { $wiki = $this->wikiService->getWiki($_GET['id']); } $this->tpl->assign('wiki', $wiki); return $this->tpl->displayPartial('wiki.wikiDialog'); } /** * Creates or updates a wiki (notebook). The controller gate defers (entityScoped) to the * service's createWiki/updateWiki, which authorize CREATE/EDIT against the wiki's real project. * * @throws BindingResolutionException */ #[RequiresPermission(WikiPermissions::EDIT, entityScoped: true)] public function post($params): Response { $wiki = app()->make(Wiki::class); if (isset($_GET['id'])) { $id = (int) $_GET['id']; // Update $wiki->title = $params['title']; $this->wikiService->updateWiki($wiki, $id); $this->tpl->setNotification('notification.wiki_updated_successfully', 'success', 'wiki_updated'); return Frontcontroller::redirect(BASE_URL.'/wiki/wikiModal/'.$id); } else { // New $wiki->title = $params['title']; $wiki->projectId = session('currentProject'); $wiki->author = session('userdata.id'); $id = $this->wikiService->createWiki($wiki); // session(["currentWiki" => $id]); if ($id) { $this->tpl->setNotification('notification.wiki_created_successfully', 'success', 'wiki_created'); return Frontcontroller::redirect(BASE_URL.'/wiki/wikiModal/'.$id.'?closeModal=1'); } return Frontcontroller::redirect(BASE_URL.'/wiki/wikiModal/'.$id.''); } } }