OpenXE/classes/Modules/Api/Dashboard/WidgetResult.php

40 lines
754 B
PHP
Raw Normal View History

2021-05-21 08:49:41 +02:00
<?php
namespace Xentral\Modules\Api\Dashboard;
use Xentral\Modules\Api\Resource\Result\AbstractResult;
final class WidgetResult extends AbstractResult
{
/**
* @param array $data
* @param array $pagination
*/
public function __construct(array $data, array $pagination = null)
{
$this->data = $data;
}
/**
* @return array
*/
public function getData()
{
$data = [];
foreach ($this->data as $item) {
/** @var WidgetData $item */
$data[] = $item->toArray();
}
return $data;
}
/**
* @param WidgetData $widgetData
*/
public function addData(WidgetData $widgetData)
{
$this->data[] = $widgetData;
}
}