Data Providers & Row Mappers
With AbstractDataTable, providers are resolved internally and row mapping is applied through a
pipeline. The usual extension points are:
createDataProvider()for custom providersmapRow()for domain-to-array mappingcreateRowMapper()when you need the built-in mapping/template/action pipeline instance
DataProviderInterface
use Pentiminax\UX\DataTables\DataTableRequest\DataTableRequest;
use Pentiminax\UX\DataTables\Model\DataTableResult;
interface DataProviderInterface
{
public function fetchData(DataTableRequest $request): DataTableResult;
}
Built-in providers:
| Provider | Use case |
|---|---|
| `DoctrineDataProvider` | Doctrine ORM-backed datasets |
| `ArrayDataProvider` | In-memory or preloaded arrays |
RowMapperInterface
interface RowMapperInterface
{
public function map(mixed $row): array;
}
Built-in mappers and processors:
| Mapper | Use case |
|---|---|
| `DefaultRowMapper` | Default row-to-array mapping behavior |
| `ClosureRowMapper` | Custom mapping logic via closure |
| `RowProcessingPipeline` | Internal pipeline used by `AbstractDataTable` |
DataTableResult
new DataTableResult(
recordsTotal: 1000,
recordsFiltered: 150,
data: $rows,
);
When To Implement Custom Types
- custom domain filters with non-Doctrine backends
- APIs requiring specific output shape
- performance tuning with pre-mapped row payloads
Manual Provider Example
use Pentiminax\UX\DataTables\Contracts\DataProviderInterface;
use Pentiminax\UX\DataTables\DataProvider\ArrayDataProvider;
protected function createDataProvider(): ?DataProviderInterface
{
return new ArrayDataProvider($this->rows, $this->createRowMapper());
}