]> BookStack Code Mirror - bookstack/blob - app/Permissions/SimpleEntityData.php
CSS: Updated status colors to be CSS variables, Added dark variants
[bookstack] / app / Permissions / SimpleEntityData.php
1 <?php
2
3 namespace BookStack\Permissions;
4
5 use BookStack\Entities\Models\Entity;
6
7 class SimpleEntityData
8 {
9     public int $id;
10     public string $type;
11     public int $owned_by;
12     public ?int $book_id;
13     public ?int $chapter_id;
14
15     public static function fromEntity(Entity $entity): self
16     {
17         $attrs = $entity->getAttributes();
18         $simple = new self();
19
20         $simple->id = $attrs['id'];
21         $simple->type = $entity->getMorphClass();
22         $simple->owned_by = $attrs['owned_by'] ?? 0;
23         $simple->book_id = $attrs['book_id'] ?? null;
24         $simple->chapter_id = $attrs['chapter_id'] ?? null;
25
26         return $simple;
27     }
28 }