コード例 #1
0
ファイル: PageRepo.php プロジェクト: crono/BookStack
 /**
  * Changes the related book for the specified page.
  * Changes the book id of any relations to the page that store the book id.
  * @param int  $bookId
  * @param Page $page
  * @return Page
  */
 public function changeBook($bookId, Page $page)
 {
     $page->book_id = $bookId;
     foreach ($page->activity as $activity) {
         $activity->book_id = $bookId;
         $activity->save();
     }
     $page->slug = $this->findSuitableSlug($page->name, $bookId, $page->id);
     $page->save();
     return $page;
 }
コード例 #2
0
ファイル: PageRepo.php プロジェクト: nwalke/BookStack
 /**
  * Change the page's parent to the given entity.
  * @param Page $page
  * @param Entity $parent
  */
 public function changePageParent(Page $page, Entity $parent)
 {
     $book = $parent->isA('book') ? $parent : $parent->book;
     $page->chapter_id = $parent->isA('chapter') ? $parent->id : 0;
     $page->save();
     $page = $this->changeBook($book->id, $page);
     $page->load('book');
     $this->permissionService->buildJointPermissionsForEntity($book);
 }