X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FBaseCollection.php;h=0bf46f0dcb73d95d3639afe60f58a3a56ff85c54;hb=036b565a7846916f763ce1dcbcaade0844ff1589;hp=1aa13ae9611403df74bd3078f4b83bcd2989bfa2;hpb=3d97149007872d69ca43ec955137b887d95239cf;p=friendica.git diff --git a/src/BaseCollection.php b/src/BaseCollection.php index 1aa13ae961..0bf46f0dcb 100644 --- a/src/BaseCollection.php +++ b/src/BaseCollection.php @@ -1,6 +1,6 @@ getArrayCopy(), $column, $index_key); + return array_column($this->getArrayCopy(true), $column, $index_key); } /** @@ -124,4 +124,21 @@ class BaseCollection extends \ArrayIterator { return new static(array_reverse($this->getArrayCopy()), $this->getTotalCount()); } + + /** + * @inheritDoc + * + * includes recursion for entity::toArray() function + * @see BaseEntity::toArray() + */ + public function getArrayCopy(bool $recursive = false): array + { + if (!$recursive) { + return parent::getArrayCopy(); + } + + return array_map(function ($item) { + return is_object($item) ? $item->toArray() : $item; + }, parent::getArrayCopy()); + } }