Skip to content
docsv0.1.0

ArrayDataSource

A {@see DataSourceInterface} backed by a fixed, in-process PHP array — the simplest data source, for static lookups, fixtures, and tests. Matches against `label`/`value`/`search` (case-insensitive substring), truncated to {@see DataSourceRequest::$limit}.

ArrayDataSource::__construct()

public function __construct(string $name, array $items):

Parameters

Parameters of __construct()
NameTypeDescription
$namestring
$itemsarray<int, array<string, mixed>>

ArrayDataSource::supports()

public function supports(string $source): bool

True when `$source` matches this data source's registered name.

Parameters

Parameters of supports()
NameTypeDescription
$sourcestring

ArrayDataSource::resolve()

public function resolve(Milpa\Live\ValueObjects\DataSourceRequest $request): Milpa\Live\ValueObjects\DataSourceResult

Filters `$items` by {@see DataSourceRequest::$query} (case-insensitive substring match against `label`/`value`/`search`), then truncates to {@see DataSourceRequest::$limit}; `$result->meta['truncated']` reports whether the match set was larger than the returned page.

Parameters

Parameters of resolve()
NameTypeDescription
$requestMilpa\Live\ValueObjects\DataSourceRequest