src/Leevel/Tree/Tree.php
public function normalize(Closure $callables = null, array $key = [], $id = 0): array
    {
        $data = [];

        foreach ($this->getChild($id) as $value) {
            $item = [
                $key['value'] ?? 'value' => $value,
                $key['data'] ?? 'data'   => $this->data[$value],
            ];

            if ($callables) {
                $result = $callables($item, $this);

                if (null !== $result) {
                    $item = $result;
                }
            }

            if ($children = $this->normalize($callables, $key, $value)) {
                $item[$key['children'] ?? 'children'] = $children;
            }

            $data[] = $item;
        }

        return $data;
    }
public function normalize(Closure $callables = null, array $key = [], $id = 0): array
    {
        $data = [];

        foreach ($this->getChild($id) as $value) {
            $item = [
                $key['value'] ?? 'value' => $value,
                $key['data'] ?? 'data'   => $this->data[$value],
            ];

            if ($callables) {
                $result = $callables($item, $this);

                if (null !== $result) {
                    $item = $result;
                }
            }

            if ($children = $this->normalize($callables, $key, $value)) {
                $item[$key['children'] ?? 'children'] = $children;
            }

            $data[] = $item;
        }

        return $data;
    }
树转化为数组.

@param \Closure   $callables
@param array      $key
@param int|string $id

@return array