Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/Database/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,24 @@ public function __construct(array $input = [])
throw new StructureException('$permissions must be of type array');
}

foreach ($input as $key => &$value) {
foreach ($input as $key => $value) {
if (!\is_array($value)) {
continue;
}
if ((isset($value['$id']) || isset($value['$collection']))) {

if (isset($value['$id']) || isset($value['$collection'])) {
$input[$key] = new self($value);
continue;
}

foreach ($value as $childKey => $child) {
if ((isset($child['$id']) || isset($child['$collection'])) && (!$child instanceof self)) {
$value[$childKey] = new self($child);
}
}
}

unset($value); // Unset Reference
$input[$key] = $value;
}

parent::__construct($input);
}
Expand Down