Skip to content
Corex

TableDataSource

Corex\Config\Data\TableDataSource · class · Config layer

A DataSource over a Corex-managed custom table (spec 038): it exposes the table’s declared columns and shapes each row to id + exactly those columns (extra columns dropped, missing ones defaulted to ”), so a managed table appears in Corex → Data like any other source with no new UI. The $wpdb access lives in the injected reader, so this shaping is unit-tested. Capabilities are derived from the table’s declaration rather than asserted here (spec 074), so a table that declares nothing stays read-only and cannot advertise an operation it never agreed to. Writes and migrations arrive through {@see WritableTableDataSource}, which is the subclass the registry builds when — and only when — the declaration asks for them.

__construct(ManagedTable $table, TableDataReader $reader)

Section titled “__construct(ManagedTable $table, TableDataReader $reader)”

The group its table is in: the table’s two words are this interface’s two.

The paged list. Shaped through {@see shapeRows()} like every other read path. It used to inline its own copy of the same loop, which is how it missed the attachment hydration query() and record() got: the Data screen’s list showed 21848 where its detail modal showed a link, from the same column on the same table. Two loops that must agree are one loop.

A managed table’s fields are its columns, so the row its table shows is the row an export writes.

The importable shape of this source. The type used to be hardcoded to text for every column, so a table that declared an attachment column described itself as holding text and every surface downstream rendered the id as a number (#138 item 6). It reads the declared type now, through the same allow-list fields() uses, so the two cannot disagree about what a column is.

Everything this source can do, derived from the table’s declaration. Write, import, and migration flags come from the declaration and from the class being one that implements the matching interface. That makes the answer self-consistent by construction: a source can never report a capability the services would then refuse to honour, which was exactly the shape of the Import and Migrations dead ends this replaces.

The field schema, with the declared writable fields marked writable and carrying the table’s own aliases and validation — which is what the import planner and validator read.