2022-08-19 08:14:43 -04:00
|
|
|
<?php
|
|
|
|
|
2023-05-17 12:56:55 -04:00
|
|
|
namespace BookStack\References;
|
2022-08-19 08:14:43 -04:00
|
|
|
|
2024-02-07 11:37:36 -05:00
|
|
|
use BookStack\Entities\Queries\EntityQueries;
|
2023-05-18 15:53:39 -04:00
|
|
|
use BookStack\Http\Controller;
|
2022-08-19 08:14:43 -04:00
|
|
|
|
|
|
|
class ReferenceController extends Controller
|
|
|
|
{
|
2023-12-18 11:23:40 -05:00
|
|
|
public function __construct(
|
2024-02-07 11:37:36 -05:00
|
|
|
protected ReferenceFetcher $referenceFetcher,
|
|
|
|
protected EntityQueries $queries,
|
2023-12-18 11:23:40 -05:00
|
|
|
) {
|
2022-08-19 08:14:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the references to a given page.
|
|
|
|
*/
|
|
|
|
public function page(string $bookSlug, string $pageSlug)
|
|
|
|
{
|
2024-02-07 11:37:36 -05:00
|
|
|
$page = $this->queries->pages->findVisibleBySlugsOrFail($bookSlug, $pageSlug);
|
2023-12-18 11:23:40 -05:00
|
|
|
$references = $this->referenceFetcher->getReferencesToEntity($page);
|
2022-08-19 08:14:43 -04:00
|
|
|
|
2022-08-19 17:40:44 -04:00
|
|
|
return view('pages.references', [
|
2022-08-29 12:46:41 -04:00
|
|
|
'page' => $page,
|
2022-08-19 17:40:44 -04:00
|
|
|
'references' => $references,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the references to a given chapter.
|
|
|
|
*/
|
|
|
|
public function chapter(string $bookSlug, string $chapterSlug)
|
|
|
|
{
|
2024-02-07 11:37:36 -05:00
|
|
|
$chapter = $this->queries->chapters->findVisibleBySlugsOrFail($bookSlug, $chapterSlug);
|
2023-12-18 11:23:40 -05:00
|
|
|
$references = $this->referenceFetcher->getReferencesToEntity($chapter);
|
2022-08-19 17:40:44 -04:00
|
|
|
|
|
|
|
return view('chapters.references', [
|
2022-08-29 12:46:41 -04:00
|
|
|
'chapter' => $chapter,
|
2022-08-19 17:40:44 -04:00
|
|
|
'references' => $references,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the references to a given book.
|
|
|
|
*/
|
|
|
|
public function book(string $slug)
|
|
|
|
{
|
2024-02-07 11:37:36 -05:00
|
|
|
$book = $this->queries->books->findVisibleBySlugOrFail($slug);
|
2023-12-18 11:23:40 -05:00
|
|
|
$references = $this->referenceFetcher->getReferencesToEntity($book);
|
2022-08-19 17:40:44 -04:00
|
|
|
|
|
|
|
return view('books.references', [
|
2022-08-29 12:46:41 -04:00
|
|
|
'book' => $book,
|
2022-08-19 17:40:44 -04:00
|
|
|
'references' => $references,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the references to a given shelf.
|
|
|
|
*/
|
|
|
|
public function shelf(string $slug)
|
|
|
|
{
|
2024-02-07 11:37:36 -05:00
|
|
|
$shelf = $this->queries->shelves->findVisibleBySlugOrFail($slug);
|
2023-12-18 11:23:40 -05:00
|
|
|
$references = $this->referenceFetcher->getReferencesToEntity($shelf);
|
2022-08-19 17:40:44 -04:00
|
|
|
|
|
|
|
return view('shelves.references', [
|
2022-08-29 12:46:41 -04:00
|
|
|
'shelf' => $shelf,
|
2022-08-19 17:40:44 -04:00
|
|
|
'references' => $references,
|
|
|
|
]);
|
|
|
|
}
|
2022-08-19 08:14:43 -04:00
|
|
|
}
|