- Added ArrayOf attributes and DatasetFill/DatasetPull events. ArrayCollection is also working with ArrayOf attributes

This commit is contained in:
mcndave committed 2026-04-13 17:00:29 +00:00
1 parent fd5d31fa17
commit 009e30eb7e
21 files changed
+322 -43

No files matched your search

+20 -2
View File
@@ -11,11 +11,29 @@ class EntityCollection extends \ArrayObject implements \JsonSerializable {
public static function instance(array $data = [], null|string $entityClass = null) : self
{
$instance = new static($data);
$instance->entityClass = $entityClass;
if ($entityClass) {
$instance->defineEntityClass($entityClass);
}
return $instance;
}
public function defineEntityClass(string $entityClass) : self
{
if ($this->entityClass !== null) {
throw new \LogicException("This methods should only be used to convert instantiated EntityCollection outside of entities.");
}
$this->entityClass = $entityClass;
foreach($this as &$arr) {
$arr = new $entityClass($arr);
}
return $this;
}
public function filters(Callable $callback, bool $yieldValueOnly = false) : Generator
{
$idx = 0;
@@ -383,7 +401,7 @@ class EntityCollection extends \ArrayObject implements \JsonSerializable {
$className = $entityClass ?: $this->entityClass;
return ( new $className() )->fromArray($dataset);
return new $className($dataset) ;
}
public function arrayToEntities(array $list, ? string /*stringable*/ $entityClass = null) : self