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,
18 * Find an entity via an identifier string in the format:
22 public function findVisibleByStringIdentifier(string $identifier): ?Entity
24 $explodedId = explode(':', $identifier);
25 $entityType = $explodedId[0];
26 $entityId = intval($explodedId[1]);
28 /** @var ?ProvidesEntityQueries $queries */
29 $queries = match ($entityType) {
30 'page' => $this->pages,
31 'chapter' => $this->chapters,
32 'book' => $this->books,
33 'bookshelf' => $this->shelves,
37 if (is_null($queries)) {
41 return $queries->findVisibleById($entityId);