Celerik\Ui\Data
ArrayDataSource
final class Celerik\Ui\Data\ArrayDataSource implements DataSourceInterface
In-memory data source for plain PHP arrays (framework-free apps, fixtures, tests).
Methods
__construct
__construct(array $rows)fetch
fetch(DataRequest $request): DataResultArrayEventSource
final class Celerik\Ui\Data\ArrayEventSource implements EventSourceInterface
In-memory event source for plain PHP arrays, fixtures and tests.
Methods
__construct
__construct(iterable $events)between
between(DateRange $range): iterableDataRequest
final class Celerik\Ui\Data\DataRequest
Normalized paging, sorting, search and filter parameters.
Built from query parameters in either of two formats:
- DataTables server-side protocol: draw, start, length, order[i][column|dir], columns[i][data], search[value]
- Celerik simple format: page, per_page, sort=name,-created_at, search, filter[field]=value
Constants
| Constant | Value |
|---|---|
FIELD_PATTERN | '/^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)?$/' |
MAX_PER_PAGE | 1000 |
MAX_SEARCH_LENGTH | 255 |
LIKE_ESCAPE | '!' |
Methods
__construct
__construct(int $page = 1, int $perPage = 10, array $sort = [], ?string $search = null, array $filters = [], array $searchFields = [], int $draw = 0)$searchFields: Fields the search term applies to; empty lets the source decide.
fromArray
static fromArray(array $query, ?array $sortable = null, ?array $searchable = null, int $defaultPerPage = 10): self$sortable: Fields the client may sort on; null allows any valid field name.$searchable: Fields searched and allowed as filters; null allows any valid field name.
offset
offset(): intlikePattern
likePattern(): ?stringThe search term as a "contains" LIKE pattern, with % and _ matched literally. Use it with an explicit escape clause: LIKE ? ESCAPE '!' (see LIKE_ESCAPE).
isValidField
static isValidField(string $field): boolDataResult
final class Celerik\Ui\Data\DataResult implements JsonSerializable
One page of rows plus the metadata every Celerik endpoint returns:
{"data": [...], "meta": {"page", "perPage", "total", "filtered", "draw", "sort", "search", "filters"}}Methods
__construct
__construct(array $rows, int $total, int $filtered, DataRequest $request)$total: Row count before search and filters.$filtered: Row count after search and filters, before paging.
map
map(callable $callback): selfReturns a copy with transformed rows (used to project rows onto the declared columns).
toArray
toArray(): arrayjsonSerialize
jsonSerialize(): arrayDataSourceInterface
interface Celerik\Ui\Data\DataSourceInterface
A source of rows for data-bound components (Grid today, Scheduler and others later).
Field names in the request are already validated against FIELD_PATTERN and the component's whitelist, so implementations may use them as column names.
Methods
fetch
fetch(DataRequest $request): DataResultDateRange
final class Celerik\Ui\Data\DateRange
The visible date range FullCalendar asks events for: ?start=...&end=... (end exclusive).
Constants
| Constant | Value |
|---|---|
MAX_DAYS | 400 |
Methods
__construct
__construct(DateTimeImmutable $start, DateTimeImmutable $end)fromQuery
static fromQuery(array $query, ?DateTimeZone $timeZone = null): selfoverlaps
overlaps(Event $event): boolWhether an event is at least partly inside the range.
Event
final class Celerik\Ui\Data\Event implements JsonSerializable
A calendar event, validated on construction and serialized in FullCalendar's format.
All-day events use an exclusive end date, as FullCalendar does: a one-day event on 2026-11-05 has start 2026-11-05 and no end (or end 2026-11-06).
Constants
| Constant | Value |
|---|---|
MAX_TITLE_LENGTH | 255 |
Methods
__construct
__construct(string $title, DateTimeImmutable $start, ?DateTimeImmutable $end = null, bool $allDay = false, string|int|null $id = null, ?string $color = null, ?string $url = null, array $extra = [])fromArray
static fromArray(array $data, ?DateTimeZone $timeZone = null): selfBuilds an event from request data or a database row.
Keys: title, start, end, allDay, id, color, url, extendedProps (or extra). allDay defaults to true when start is a plain date such as "2026-11-05".
toArray
toArray(): arrayjsonSerialize
jsonSerialize(): arraytextColorFor
static textColorFor(?string $color): ?stringBlack or white, whichever contrasts more with a hex color (WCAG relative luminance).
EventResult
final class Celerik\Ui\Data\EventResult implements JsonSerializable
Events for one date range, in the standard Celerik envelope:
{"data": [{"id", "title", "start", "end", "allDay"...}], "meta": {"start", "end", "count"}}Methods
__construct
__construct(array $events, DateRange $range)toArray
toArray(): arrayjsonSerialize
jsonSerialize(): arrayEventSourceInterface
interface Celerik\Ui\Data\EventSourceInterface
A source of calendar events for the Scheduler.
Methods
between
between(DateRange $range): iterableEvents that overlap the range (start inclusive, end exclusive).