CoolCMS API

BaseColumn
in package

AbstractYes

Common base of grid columns. A column is a plain configuration object (no DI service, see the exclude in config/common.neon), built fluently as `Column::create('name')->setLabel(…)->…` and passed ready to {@see \App\UI\Admin\System\Components\DataGridComponent\DataGrid::addColumn()}.

name identifies the column: key for sorting (persistent orderBy) and for search values (persistent filters[name]).

Table of Contents

Properties

$filter  : ColumnFilter|null
$hiddenInPickerMode  : bool
$hiddenInReorderMode  : bool
$htmlAttributes  : array<string, string>
$label  : string
$linkDestination  : string|null
Target destination of the link wrapping the cell content; null means no link.
$linkParams  : array<string, string>
$linkRequiredParams  : array<string|int, string>|null
Names of URL parameters that must be filled (not null / '') after mapping, otherwise the link is not generated. null requires all ({@see getLinkRequiredParams()}).
$linkTarget  : string|null
$name  : string
$renderer  : CellRenderer|null
$sortable  : bool
$sortBy  : string|null
$treeIndent  : bool
$width  : int|null

Methods

__construct()  : mixed
create()  : static
getFilter()  : ColumnFilter|null
getHtmlAttributes()  : array<string, string>
getLabel()  : string
getLinkDestination()  : string|null
getLinkParams()  : array<string, string>
getLinkRequiredParams()  : array<string|int, string>
Names of URL parameters that must be filled for the link to be generated.
getLinkTarget()  : string|null
getName()  : string
getProperties()  : array<string|int, string>
Dotted property paths the column works on (filter, value).
getRenderer()  : CellRenderer
Cell renderer; plain text unless set explicitly.
getSortBy()  : string|null
getValue()  : mixed
Cell value for the given row (entity).
getWidth()  : int|null
hasTreeIndent()  : bool
hideInPickerMode()  : static
The column is hidden when the grid runs in picker mode (selection modal).
hideInReorderMode()  : static
The column is hidden in the reorder mode (nested drag & drop view).
isSortable()  : bool
isVisibleInPickerMode()  : bool
isVisibleInReorderMode()  : bool
setFilter()  : static
setHtmlAttribute()  : static
Adds an HTML attribute to the column cell (`<td>` in a flat table, the cell in the tree view).
setHtmlClass()  : static
Shorthand for {@see setHtmlAttribute()} with the `class` attribute.
setLabel()  : static
setLink()  : static
Wraps the whole cell content in a link to a presenter action. Works with any renderer (text, name via {@see MultiColumn}, badge, …). Link parameters are mapped from the row properties: `setLink(':Admin:System:User:edit', ['id' => 'id'])` fills URL parameter `id` with the `id` property of the entity.
setRenderer()  : static
setSortable()  : static
setSortBy()  : static
Explicit path for ORDER BY; defaults to the first property of the column.
setTreeIndent()  : static
In tree mode the cell is indented by the record level (typically the name column).
setWidth()  : static
Column width in percent (CSS class `width-X`).
resolve()  : mixed

Properties

$hiddenInPickerMode

protected bool $hiddenInPickerMode = false

$hiddenInReorderMode

protected bool $hiddenInReorderMode = false

$htmlAttributes

protected array<string, string> $htmlAttributes = []

HTML attribute => value (rendered on the column cell)

$linkDestination

Target destination of the link wrapping the cell content; null means no link.

protected string|null $linkDestination = null

$linkParams

protected array<string, string> $linkParams = []

URL parameter => entity property path

$linkRequiredParams

Names of URL parameters that must be filled (not null / '') after mapping, otherwise the link is not generated. null requires all ({@see getLinkRequiredParams()}).

protected array<string|int, string>|null $linkRequiredParams = null

$linkTarget

protected string|null $linkTarget = null

Methods

__construct()

public final __construct(string $name) : mixed
Parameters
$name : string

create()

public static create(string $name) : static
Parameters
$name : string
Return values
static

getHtmlAttributes()

public getHtmlAttributes() : array<string, string>
Return values
array<string, string> —

HTML attributes of the cell (name => value)

getLabel()

public getLabel() : string
Return values
string

getLinkDestination()

public getLinkDestination() : string|null
Return values
string|null

getLinkParams()

public getLinkParams() : array<string, string>
Return values
array<string, string>

getLinkRequiredParams()

Names of URL parameters that must be filled for the link to be generated.

public getLinkRequiredParams() : array<string|int, string>

All mapped parameters unless set explicitly.

Return values
array<string|int, string>

getLinkTarget()

public getLinkTarget() : string|null
Return values
string|null

getName()

public getName() : string
Return values
string

getProperties()

Dotted property paths the column works on (filter, value).

public abstract getProperties() : array<string|int, string>
Return values
array<string|int, string>

getSortBy()

public getSortBy() : string|null
Return values
string|null

getValue()

Cell value for the given row (entity).

public abstract getValue(object $entity[, int|null $langId = null ]) : mixed
Parameters
$entity : object
$langId : int|null = null

getWidth()

public getWidth() : int|null
Return values
int|null

hasTreeIndent()

public hasTreeIndent() : bool
Return values
bool

hideInPickerMode()

The column is hidden when the grid runs in picker mode (selection modal).

public hideInPickerMode([bool $hide = true ]) : static
Parameters
$hide : bool = true
Return values
static

hideInReorderMode()

The column is hidden in the reorder mode (nested drag & drop view).

public hideInReorderMode([bool $hide = true ]) : static
Parameters
$hide : bool = true
Return values
static

isSortable()

public isSortable() : bool
Return values
bool

isVisibleInPickerMode()

public isVisibleInPickerMode() : bool
Return values
bool

isVisibleInReorderMode()

public isVisibleInReorderMode() : bool
Return values
bool

setHtmlAttribute()

Adds an HTML attribute to the column cell (`<td>` in a flat table, the cell in the tree view).

public setHtmlAttribute(string $name, string $value) : static

Can be called repeatedly for more attributes; the same name overwrites the previous value. class is merged with the internal cell classes (tree indent), other attributes are rendered unchanged.

setHtmlAttribute('class', 'highlight'), setHtmlAttribute('data-id', '5').

Parameters
$name : string
$value : string
Return values
static

setHtmlClass()

Shorthand for {@see setHtmlAttribute()} with the `class` attribute.

public setHtmlClass(string $class) : static
Parameters
$class : string
Return values
static

setLabel()

public setLabel(string $label) : static
Parameters
$label : string
Return values
static

Wraps the whole cell content in a link to a presenter action. Works with any renderer (text, name via {@see MultiColumn}, badge, …). Link parameters are mapped from the row properties: `setLink(':Admin:System:User:edit', ['id' => 'id'])` fills URL parameter `id` with the `id` property of the entity.

public setLink(string|null $destination[, array<string, string> $params = [] ][, string|null $target = null ][, array<string|int, string>|null $requiredParams = null ]) : static

Do not use on columns whose renderer produces <a> itself (EmailRenderer, LinkRenderer, toggle, …): the link would be nested and invalid. Use that renderer directly.

$destination === null disables the link, useful for conditional wiring by privilege: setLink($canEdit ? ':Admin:System:User:edit' : null, …).

$requiredParams says which mapped parameters must be filled (not null / ''), otherwise the link is not generated; this guards against broken links and a link() crash on a missing id (id from a null property). Default null requires all parameters; ['id'] only the listed ones; [] none (the link is always generated, even with null parameters).

Parameters
$destination : string|null
$params : array<string, string> = []

URL parameter => entity property path

$target : string|null = null
$requiredParams : array<string|int, string>|null = null

names of required URL parameters (null = all)

Return values
static

setSortable()

public setSortable([bool $sortable = true ]) : static
Parameters
$sortable : bool = true
Return values
static

setSortBy()

Explicit path for ORDER BY; defaults to the first property of the column.

public setSortBy(string|null $sortBy) : static
Parameters
$sortBy : string|null
Return values
static

setTreeIndent()

In tree mode the cell is indented by the record level (typically the name column).

public setTreeIndent([bool $treeIndent = true ]) : static
Parameters
$treeIndent : bool = true
Return values
static

setWidth()

Column width in percent (CSS class `width-X`).

public setWidth(int|null $width) : static
Parameters
$width : int|null
Return values
static

resolve()

protected resolve(object $entity, string $path, int|null $langId) : mixed
Parameters
$entity : object
$path : string
$langId : int|null
On this page

Search results