- Added Events to repository and entitytrait objects. Some more work to be done on this.

- Diverses bug fixes linked to join and relations
- Field date and datetime are now outputed using given locale.
This commit is contained in:
Dave Mc Nicoll committed 2020-05-20 15:34:50 -04:00
1 parent 1839726dc0
commit 4d221859fc
15 files changed
+421 -99

No files matched your search

+21 -5
View File
@@ -47,23 +47,39 @@ class EntityCollection extends \ArrayObject {
}
}
public function buildArray(string $keyColumn, /* string|callable */ $value) : array
public function buildArray(string $keyColumn, /* string|callable|null */ $value = null) : array
{
$list = [];
foreach($this as $key => $item) {
foreach($this as $item) {
switch (true) {
case is_string($value):
$list[$item->$keyColumn] = $item->$value;
case is_null($value):
$list[] = $item->$keyColumn;
break;
case is_callable($value):
$list[$item->$keyColumn] = $value($item);
break;
case is_object($value):
case is_string($value):
$value = (string) $value;
$list[$item->$keyColumn] = $item->$value;
break;
}
}
return $list;
}
public function toArray(bool $includeRelations = false) : array {
$list = [];
foreach($this as $entity) {
$list[] = $entity->toArray($includeRelations);
}
return $list;
}
}