2022-07-12 16:13:02 -04:00
|
|
|
<?php
|
|
|
|
|
2023-05-17 12:56:55 -04:00
|
|
|
namespace BookStack\Permissions;
|
2022-07-12 16:13:02 -04:00
|
|
|
|
2023-01-23 10:09:03 -05:00
|
|
|
use BookStack\Entities\Models\Entity;
|
|
|
|
|
2022-07-12 16:13:02 -04:00
|
|
|
class SimpleEntityData
|
|
|
|
{
|
|
|
|
public int $id;
|
|
|
|
public string $type;
|
|
|
|
public int $owned_by;
|
|
|
|
public ?int $book_id;
|
|
|
|
public ?int $chapter_id;
|
2023-01-23 10:09:03 -05:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2022-07-17 05:32:16 -04:00
|
|
|
}
|