1 <?php namespace BookStack\Entities;
6 * Provides access to the core entity models.
7 * Wrapped up in this provider since they are often used together
8 * so this is a neater alternative to injecting all in individually.
10 * @package BookStack\Entities
41 * EntityProvider constructor.
43 public function __construct(
48 PageRevision $pageRevision
50 $this->bookshelf = $bookshelf;
52 $this->chapter = $chapter;
54 $this->pageRevision = $pageRevision;
58 * Fetch all core entity types as an associated array
59 * with their basic names as the keys.
61 public function all(): array
64 'bookshelf' => $this->bookshelf,
65 'book' => $this->book,
66 'chapter' => $this->chapter,
67 'page' => $this->page,
72 * Get an entity instance by it's basic name.
74 public function get(string $type): Entity
76 $type = strtolower($type);
77 return $this->all()[$type];
81 * Get the morph classes, as an array, for a single or multiple types.
83 public function getMorphClasses(array $types): array
86 foreach ($types as $type) {
87 $model = $this->get($type);
88 $morphClasses[] = $model->getMorphClass();