designtopack/public/site/plugins/classes/location/Location.php
2025-01-15 16:27:08 +01:00

53 lines
1.4 KiB
PHP

<?php
namespace adrienpayet\D2P\data\location;
class Location
{
protected PageDetails $page;
// protected ?string $dialogUri = null;
// protected ProjectDetails $project;
protected ?FileDetails $file = null;
protected ?array $parent = null;
public function __construct(array $data)
{
$this->page = new PageDetails($data["page"]);
// $this->dialogUri = $data["dialogUri"];
// $this->project = new ProjectDetails($data["project"]);
if (isset($data['file'])) {
$this->file = new FileDetails($data["file"]);
}
if (isset($data["parent"])) {
$this->parent = [
"author" => [
"name" => $data["parent"]["author"]["name"],
"email" => $data["parent"]["author"]["email"],
],
"id" => $data["parent"]["id"]
];
}
}
public function toArray() {
$array = [
"page" => $this->page->toArray(),
// "project" => $this->project->toArray(),
];
// if ($this->dialogUri) {
// $array["dialogUri"] = $this->dialogUri;
// }
if ($this->file) {
$array["file"] = $this->file;
}
if ($this->parent) {
$array["parent"] = $this->parent;
}
return $array;
}
}