Skip to content

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 ​

php
__construct(array $rows)

fetch ​

php
fetch(DataRequest $request): DataResult

ArrayEventSource ​

final class Celerik\Ui\Data\ArrayEventSource implements EventSourceInterface

In-memory event source for plain PHP arrays, fixtures and tests.

Methods ​

__construct ​

php
__construct(iterable $events)

between ​

php
between(DateRange $range): iterable

DataRequest ​

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 ​

ConstantValue
FIELD_PATTERN'/^[A-Za-z_][A-Za-z0-9_]*(\\.[A-Za-z_][A-Za-z0-9_]*)?$/'
MAX_PER_PAGE1000
MAX_SEARCH_LENGTH255
LIKE_ESCAPE'!'

Methods ​

__construct ​

php
__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 ​

php
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 ​

php
offset(): int

likePattern ​

php
likePattern(): ?string

The search term as a "contains" LIKE pattern, with % and _ matched literally. Use it with an explicit escape clause: LIKE ? ESCAPE '!' (see LIKE_ESCAPE).

isValidField ​

php
static isValidField(string $field): bool

DataResult ​

final class Celerik\Ui\Data\DataResult implements JsonSerializable

One page of rows plus the metadata every Celerik endpoint returns:

php
{"data": [...], "meta": {"page", "perPage", "total", "filtered", "draw", "sort", "search", "filters"}}

Methods ​

__construct ​

php
__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 ​

php
map(callable $callback): self

Returns a copy with transformed rows (used to project rows onto the declared columns).

toArray ​

php
toArray(): array

jsonSerialize ​

php
jsonSerialize(): array

DataSourceInterface ​

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 ​

php
fetch(DataRequest $request): DataResult

DateRange ​

final class Celerik\Ui\Data\DateRange

The visible date range FullCalendar asks events for: ?start=...&end=... (end exclusive).

Constants ​

ConstantValue
MAX_DAYS400

Methods ​

__construct ​

php
__construct(DateTimeImmutable $start, DateTimeImmutable $end)

fromQuery ​

php
static fromQuery(array $query, ?DateTimeZone $timeZone = null): self

overlaps ​

php
overlaps(Event $event): bool

Whether 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 ​

ConstantValue
MAX_TITLE_LENGTH255

Methods ​

__construct ​

php
__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 ​

php
static fromArray(array $data, ?DateTimeZone $timeZone = null): self

Builds 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 ​

php
toArray(): array

jsonSerialize ​

php
jsonSerialize(): array

textColorFor ​

php
static textColorFor(?string $color): ?string

Black 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:

php
{"data": [{"id", "title", "start", "end", "allDay"...}], "meta": {"start", "end", "count"}}

Methods ​

__construct ​

php
__construct(array $events, DateRange $range)

toArray ​

php
toArray(): array

jsonSerialize ​

php
jsonSerialize(): array

EventSourceInterface ​

interface Celerik\Ui\Data\EventSourceInterface

A source of calendar events for the Scheduler.

Methods ​

between ​

php
between(DateRange $range): iterable

Events that overlap the range (start inclusive, end exclusive).

Released under the MIT License.