getAction() == 'delete') { try { $page = $this->getPage($type); $json = $page->getDefaultJson(); $this->deleteSQL('pages', ['type' => $type]); $page->createPage(); } catch (\Exception $exception) { $this->returnError($exception->getMessage()); } } if (getVal('preview')) { $vars['redirect'] = $this->getPage($type)->getUrl(); } else { $page = $this->getPage($type); $vars['redirect'] = $page->getUrl(); } } catch (UnknownPageTypeException $e) { $errStr = sprintf(translate('errorNotFound', 'base'), $this->translateType(), $this->getID()); throw new NotFoundHttpException($errStr); } } $vars['preview'] = getVal('preview'); return $vars; } public function returnError($ErrStr, $parentRefresh = '', $ID = null) { redirect('launch.php?s=PagesFragments.php&refresh=close&ErrStr='.urlencode($ErrStr)); } public function handle() { if ($type = getVal('ID')) { // activate page if (!$this->selectSQL('pages', ['type' => $type])->fetch()) { try { $page = $this->getPage($type); $page->createPage(); } catch (UnknownPageTypeException $e) { } } } } private function getPage($type) { /** @var PageLocator $pageLocator */ $pageLocator = ServiceContainer::getService(PageLocator::class); return $pageLocator->getPageService($type); } } return Pages::class;