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.
60 * @return [string => Entity]
62 public function all(): array
65 'bookshelf' => $this->bookshelf,
66 'book' => $this->book,
67 'chapter' => $this->chapter,
68 'page' => $this->page,
73 * Get an entity instance by it's basic name.
75 public function get(string $type): Entity
77 $type = strtolower($type);
78 return $this->all()[$type];
82 * Get the morph classes, as an array, for a single or multiple types.
84 public function getMorphClasses(array $types): array
87 foreach ($types as $type) {
88 $model = $this->get($type);
89 $morphClasses[] = $model->getMorphClass();