RelationColumn
extends BaseColumn
in package
Column whose cell does not match an entity column but a flag from a related collection selected by a "scope". Built for matrices (row = entity, column = one of dynamically generated items), typically the RBAC matrix where the row is a privilege, `userRoleRels` its collection of links and scope = roleId.
getValue() walks collectionProperty, finds the element whose matchProperty equals scope
and returns its valueProperty (bool); when none exists it returns false (link not allowed).
The column is neither sorted nor filtered in SQL (getProperties() = []) because the value is
derived in PHP. Writing is done by RelationToggleRenderer via the relationToggle! signal
(see RelationTogglable).
Usage:
RelationColumn::create('role_' . $roleId)
->setLabel($roleName)
->setRelation('userRoleRels', 'userRoleId', 'allowed')
->setScope($roleId)
->setToggleLabels($yesLabel, $noLabel);
Table of Contents
Properties
- $collectionProperty : string
- $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
- $matchProperty : string
- $name : string
- $renderer : CellRenderer|null
- $scope : int|string
- $sortable : bool
- $sortBy : string|null
- $treeIndent : bool
- $valueProperty : string
- $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.
- getScope() : int|string
- 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.
- setRelation() : static
- setRenderer() : static
- setScope() : static
- setSortable() : static
- setSortBy() : static
- Explicit path for ORDER BY; defaults to the first property of the column.
- setToggleLabels() : static
- Shorthand: yes/no toggle over this relation 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
- callGetter() : mixed
- resolveCollection() : iterable<string|int, mixed>
Properties
$collectionProperty
protected
string
$collectionProperty
= ''
$filter
protected
ColumnFilter|null
$filter
= null
$hiddenInPickerMode
protected
bool
$hiddenInPickerMode
= false
$hiddenInReorderMode
protected
bool
$hiddenInReorderMode
= false
$htmlAttributes
protected
array<string, string>
$htmlAttributes
= []
HTML attribute => value (rendered on the column cell)
$label
protected
string
$label
= ''
$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
$matchProperty
protected
string
$matchProperty
= ''
$name read-only
protected
string
$name
$renderer
protected
CellRenderer|null
$renderer
= null
$scope
protected
int|string
$scope
= ''
$sortable
protected
bool
$sortable
= false
$sortBy
protected
string|null
$sortBy
= null
$treeIndent
protected
bool
$treeIndent
= false
$valueProperty
protected
string
$valueProperty
= ''
$width
protected
int|null
$width
= null
Methods
__construct()
public
final __construct(string $name) : mixed
Parameters
- $name : string
create()
public
static create(string $name) : static
Parameters
- $name : string
Return values
staticgetFilter()
public
getFilter() : ColumnFilter|null
Return values
ColumnFilter|nullgetHtmlAttributes()
public
getHtmlAttributes() : array<string, string>
Return values
array<string, string> —HTML attributes of the cell (name => value)
getLabel()
public
getLabel() : string
Return values
stringgetLinkDestination()
public
getLinkDestination() : string|null
Return values
string|nullgetLinkParams()
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|nullgetName()
public
getName() : string
Return values
stringgetProperties()
Dotted property paths the column works on (filter, value).
public
getProperties() : array<string|int, string>
Return values
array<string|int, string>getRenderer()
Cell renderer; plain text unless set explicitly.
public
getRenderer() : CellRenderer
Return values
CellRenderergetScope()
public
getScope() : int|string
Return values
int|stringgetSortBy()
public
getSortBy() : string|null
Return values
string|nullgetValue()
Cell value for the given row (entity).
public
getValue(object $entity[, int|null $langId = null ]) : mixed
Parameters
- $entity : object
- $langId : int|null = null
getWidth()
public
getWidth() : int|null
Return values
int|nullhasTreeIndent()
public
hasTreeIndent() : bool
Return values
boolhideInPickerMode()
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
statichideInReorderMode()
The column is hidden in the reorder mode (nested drag & drop view).
public
hideInReorderMode([bool $hide = true ]) : static
Parameters
- $hide : bool = true
Return values
staticisSortable()
public
isSortable() : bool
Return values
boolisVisibleInPickerMode()
public
isVisibleInPickerMode() : bool
Return values
boolisVisibleInReorderMode()
public
isVisibleInReorderMode() : bool
Return values
boolsetFilter()
public
setFilter(ColumnFilter|null $filter) : static
Parameters
- $filter : ColumnFilter|null
Return values
staticsetHtmlAttribute()
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
staticsetHtmlClass()
Shorthand for {@see setHtmlAttribute()} with the `class` attribute.
public
setHtmlClass(string $class) : static
Parameters
- $class : string
Return values
staticsetLabel()
public
setLabel(string $label) : static
Parameters
- $label : string
Return values
staticsetLink()
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
staticsetRelation()
public
setRelation(string $collectionProperty, string $matchProperty, string $valueProperty) : static
Parameters
- $collectionProperty : string
-
getter of the collection on the row entity (
userRoleRels) - $matchProperty : string
-
getter on the collection element compared with
scope(userRoleId) - $valueProperty : string
-
getter on the collection element with the bool cell value (
allowed)
Return values
staticsetRenderer()
public
setRenderer(CellRenderer|null $renderer) : static
Parameters
- $renderer : CellRenderer|null
Return values
staticsetScope()
public
setScope(int|string $scope) : static
Parameters
- $scope : int|string
Return values
staticsetSortable()
public
setSortable([bool $sortable = true ]) : static
Parameters
- $sortable : bool = true
Return values
staticsetSortBy()
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
staticsetToggleLabels()
Shorthand: yes/no toggle over this relation column.
public
setToggleLabels(string $yesLabel, string $noLabel) : static
Parameters
- $yesLabel : string
- $noLabel : string
Return values
staticsetTreeIndent()
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
staticsetWidth()
Column width in percent (CSS class `width-X`).
public
setWidth(int|null $width) : static
Parameters
- $width : int|null
Return values
staticresolve()
protected
resolve(object $entity, string $path, int|null $langId) : mixed
Parameters
- $entity : object
- $path : string
- $langId : int|null
callGetter()
private
callGetter(object $object, string $property) : mixed
Parameters
- $object : object
- $property : string
resolveCollection()
private
resolveCollection(object $entity) : iterable<string|int, mixed>
Parameters
- $entity : object