X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ee24635e06a8c01d751f80caba47c57f76e8989d..refs/pull/4002/head:/app/Auth/Permissions/SimpleEntityData.php diff --git a/app/Auth/Permissions/SimpleEntityData.php b/app/Auth/Permissions/SimpleEntityData.php index 6ec0c4179..2128451fe 100644 --- a/app/Auth/Permissions/SimpleEntityData.php +++ b/app/Auth/Permissions/SimpleEntityData.php @@ -2,12 +2,27 @@ namespace BookStack\Auth\Permissions; +use BookStack\Entities\Models\Entity; + class SimpleEntityData { public int $id; public string $type; - public bool $restricted; public int $owned_by; public ?int $book_id; public ?int $chapter_id; + + public static function fromEntity(Entity $entity): self + { + $attrs = $entity->getAttributes(); + $simple = new self(); + + $simple->id = $attrs['id']; + $simple->type = $entity->getMorphClass(); + $simple->owned_by = $attrs['owned_by'] ?? 0; + $simple->book_id = $attrs['book_id'] ?? null; + $simple->chapter_id = $attrs['chapter_id'] ?? null; + + return $simple; + } }