first version
This commit is contained in:
25
kirby/src/Cms/NestCollection.php
Executable file
25
kirby/src/Cms/NestCollection.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Kirby\Cms;
|
||||
|
||||
use Closure;
|
||||
use Kirby\Toolkit\Collection as BaseCollection;
|
||||
|
||||
class NestCollection extends BaseCollection
|
||||
{
|
||||
|
||||
/**
|
||||
* Converts all objects in the collection
|
||||
* to an array. This can also take a callback
|
||||
* function to further modify the array result.
|
||||
*
|
||||
* @param Closure $map
|
||||
* @return array
|
||||
*/
|
||||
public function toArray(Closure $map = null): array
|
||||
{
|
||||
return parent::toArray($map ?? function ($object) {
|
||||
return $object->toArray();
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user