EmailRenderer
extends CellRenderer
in package
E-mail address as a clickable link. Without configuration it renders a `mailto:` link (`<a href="mailto:…">`); after {@see setDestination()} it behaves like {@see LinkRenderer} and links to a presenter action (parameters mapped from row properties via {@see setParams()}).
An empty value is plain text.
Table of Contents
Properties
- $destination : string|null
- Nette destination (e.g. `:Admin:System:User:edit`); null means a `mailto:` link.
- $params : array<string, string>
- $target : string|null
Methods
- __construct() : mixed
- create() : static
- getTemplateName() : string
- Cell template name (`Cells/<type>.latte`).
- prepare() : array<string, mixed>
- Variables for the cell template.
- setDestination() : static
- Sets the link destination instead of the default `mailto:`.
- setParams() : static
- setTarget() : static
- E.g. `_blank` to open in a new window.
- toCsvValue() : string
- Plain text value of the cell for the CSV export (no HTML/JS); does not change the normal render. The default implementation looks for a text in the vars from {@see prepare()} (key `text`; true for {@see TextRenderer}, {@see ComputedRenderer}, {@see OptionRenderer}, {@see BadgeRenderer}, `Date*Renderer`) and falls back to {@see toString()}. Renderers without a text representation (bool, select, toggle) override it.
- toScalarValue() : mixed
- Column value to a scalar comparable with the keys of `options` maps: a `BackedEnum` becomes its `value`, a pure enum its `name`, a bool 0/1. Other values pass unchanged.
- toString() : string
- Column value (mixed) to text; non-stringable values give an empty string.
Properties
$destination
Nette destination (e.g. `:Admin:System:User:edit`); null means a `mailto:` link.
protected
string|null
$destination
= null
$params
protected
array<string, string>
$params
= []
URL parameter => property path
$target
protected
string|null
$target
= null
Methods
__construct()
public
final __construct() : mixed
create()
public
static create() : static
Return values
staticgetTemplateName()
Cell template name (`Cells/<type>.latte`).
public
getTemplateName() : string
Return values
stringprepare()
Variables for the cell template.
public
prepare(mixed $value, object $entity, DataGrid $grid, BaseColumn $column) : array<string, mixed>
Parameters
- $value : mixed
- $entity : object
- $grid : DataGrid
- $column : BaseColumn
Return values
array<string, mixed>setDestination()
Sets the link destination instead of the default `mailto:`.
public
setDestination(string|null $destination) : static
Without it the renderer links mailto: to the displayed address.
Parameters
- $destination : string|null
Return values
staticsetParams()
public
setParams(array<string, string> $params) : static
Parameters
- $params : array<string, string>
-
URL parameter => entity property path
Return values
staticsetTarget()
E.g. `_blank` to open in a new window.
public
setTarget(string|null $target) : static
Parameters
- $target : string|null
Return values
statictoCsvValue()
Plain text value of the cell for the CSV export (no HTML/JS); does not change the normal render. The default implementation looks for a text in the vars from {@see prepare()} (key `text`; true for {@see TextRenderer}, {@see ComputedRenderer}, {@see OptionRenderer}, {@see BadgeRenderer}, `Date*Renderer`) and falls back to {@see toString()}. Renderers without a text representation (bool, select, toggle) override it.
public
toCsvValue(mixed $value, object $entity, DataGrid $grid, BaseColumn $column) : string
Parameters
- $value : mixed
- $entity : object
- $grid : DataGrid
- $column : BaseColumn
Return values
stringtoScalarValue()
Column value to a scalar comparable with the keys of `options` maps: a `BackedEnum` becomes its `value`, a pure enum its `name`, a bool 0/1. Other values pass unchanged.
protected
toScalarValue(mixed $value) : mixed
IMPORTANT: entities return an enum object for enum columns (typed property), so without
this normalization the cell template receives an object and (string) $enum is a fatal
error, not an empty output.
Parameters
- $value : mixed
toString()
Column value (mixed) to text; non-stringable values give an empty string.
protected
toString(mixed $value) : string
An enum prints its value/name; a bool keeps the (string) semantics
(false is empty, not "0"), as the admin always printed it.
Parameters
- $value : mixed