Files
lichterei-web/kirby/src/Cms/NestObject.php
Bastian Allgeier 447a9dd266 Upgrade to 3.2.5
2019-09-24 11:00:59 +02:00

44 lines
904 B
PHP
Executable File

<?php
namespace Kirby\Cms;
use Kirby\Toolkit\Obj;
/**
* NestObject
*
* @package Kirby Cms
* @author Bastian Allgeier <bastian@getkirby.com>
* @link https://getkirby.com
* @copyright Bastian Allgeier GmbH
* @license https://getkirby.com/license
*/
class NestObject extends Obj
{
/**
* Converts the object to an array
*
* @return array
*/
public function toArray(): array
{
$result = [];
foreach ((array)$this as $key => $value) {
if (is_a($value, 'Kirby\Cms\Field') === true) {
$result[$key] = $value->value();
continue;
}
if (is_object($value) === true && method_exists($value, 'toArray')) {
$result[$key] = $value->toArray();
continue;
}
$result[$key] = $value;
}
return $result;
}
}