3 namespace BookStack\Entities\Queries;
5 use BookStack\Entities\Models\Entity;
9 public function __construct(
10 public BookshelfQueries $shelves,
11 public BookQueries $books,
12 public ChapterQueries $chapters,
13 public PageQueries $pages,
14 public PageRevisionQueries $revisions,
19 * Find an entity via an identifier string in the format:
23 public function findVisibleByStringIdentifier(string $identifier): ?Entity
25 $explodedId = explode(':', $identifier);
26 $entityType = $explodedId[0];
27 $entityId = intval($explodedId[1]);
29 /** @var ?ProvidesEntityQueries $queries */
30 $queries = match ($entityType) {
31 'page' => $this->pages,
32 'chapter' => $this->chapters,
33 'book' => $this->books,
34 'bookshelf' => $this->shelves,
38 if (is_null($queries)) {
42 return $queries->findVisibleById($entityId);