Papi_Entry_Type::merge_boxes PHP Method

merge_boxes() protected method

Merge boxes with same title.
protected merge_boxes ( array $boxes ) : array
$boxes array
return array
    protected function merge_boxes(array $boxes)
    {
        $result = [];
        foreach ($boxes as $box) {
            if (!isset($result[$box->id])) {
                $result[$box->id] = $box;
                continue;
            }
            foreach ($box->properties as $property) {
                $result[$box->id]->properties[] = $property;
            }
            $result[$box->id]->properties = array_unique($result[$box->id]->properties);
        }
        return array_values($result);
    }