Maslosoft Framework Logo Maslosoft Framework Documentation
Flexible Application Foundation


Array Provider

Array provider can be used to provide data from any source to data-related widgets. This includes Grid View from Widgets package or any case where DataProviderInterface instance is required.

Array provider still requires model. When having data as plain array, this must be assigned to model, usually created for this purpose.

Class constructor requires model type that will be used in data array. Then, after creating instance of ArrayProvider, data can be provided by calling method setData() Example of using array provider:

foreach ($result as $visits)
{
    $document = new MyModel;
    $document->visits = $visits;
    $data[] = $document;
}

$dataProvider = new ArrayProvider(MyModel::class);
$dataProvider->setData($data);