/** * @param $page_type * @param $parent_page_id * @return mixed * @throws SubPagesNotAllowed */ public function createNewPage($page_type, $parent_page_id) { $type = $this->callModuleMethod('getPageType', [$page_type]); if ($parent_page_id) { $parent = $this->getPage($parent_page_id); if (!$parent->pageType()->allowsSubPages()) { throw new SubPagesNotAllowed('This page type does not allow sub pages'); } } return $this->repository->create($type, $this->getCurrentUserId(), $parent_page_id); }