- Added support for Ignore attribute in dataset export of EntityTrait

- Work done on JSONification of entity
This commit is contained in:
mcndave committed 2023-11-17 22:40:21 -05:00
1 parent 7f8780d328
commit 3a80fee9c3
5 files changed
+60 -22

No files matched your search

+12 -1
View File
@@ -326,6 +326,17 @@ class EntityCollection extends \ArrayObject implements \JsonSerializable {
return $list;
}
public function toJsonArray(bool $includeRelations = false) : array {
$list = [];
foreach($this as $entity) {
$list[] = $entity instanceof \JsonSerializable ? $entity->jsonSerialize() : $entity->toArray($includeRelations);
}
return $list;
}
public function fromArray(array $datasets, ? string /*stringable*/ $entityClass = null) : self
{
foreach($datasets as $dataset) {
@@ -360,7 +371,7 @@ class EntityCollection extends \ArrayObject implements \JsonSerializable {
public function jsonSerialize(): mixed
{
return $this->toArray(true);
return $this->toJsonArray(true);
}
public function append($value) : void