Skip to content

Commit

Permalink
Added setPages to allow custom page list
Browse files Browse the repository at this point in the history
  • Loading branch information
HansSchouten committed Jan 3, 2025
1 parent 6b7a255 commit ec13bb0
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/Modules/GrapesJS/PageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class PageBuilder implements PageBuilderContract
*/
protected $scripts = [];

/**
* @var array $pages
*/
protected $pages = [];

/**
* @var string $css
*/
Expand Down Expand Up @@ -302,23 +307,36 @@ public function updatePage(PageContract $page, $data)
return $pageRepository->updatePageData($page, $data);
}

/**
* Set the list of all pages.
*
* @param $pages
*/
public function setPages($pages)
{
$this->pages = $pages;
}

/**
* Return the list of all pages, used in CKEditor link editor.
*
* @return array
*/
public function getPages()
{
$pages = [];
if (! empty($this->pages)) {
return $this->pages;
}

$pages = [];
$pageRepository = new PageRepository;
foreach ($pageRepository->getAll() as $page) {
$pages[] = [
phpb_e($page->getName()),
phpb_e($page->getId())
];
}

$this->pages = $pages;
return $pages;
}

Expand Down

0 comments on commit ec13bb0

Please sign in to comment.