RecordDataFormatter
extends AbstractHelper
in package
Record driver data formatting view helper
Tags
Table of Contents
- $config : Config
- Config.
- $defaults : array<string|int, mixed>
- Default settings.
- $driver : AbstractBase
- Record driver object.
- __construct() : mixed
- Constructor
- __invoke() : RecordDataFormatter
- Store a record driver object and return this object so that the appropriate data can be rendered.
- getData() : array<string|int, mixed>
- Create formatted key/value data based on a record driver and field spec.
- getDefaults() : array<string|int, mixed>
- Get default configuration.
- setDefaults() : void
- Set default configuration.
- addOptions() : array<string|int, mixed>|null
- Add global and configured options to options of a field.
- allowValue() : bool
- Should we allow a value? (Always accepts non-empty values; for empty values, allows zero when configured to do so).
- extractData() : mixed
- Extract data (usually from the record driver).
- getLink() : string|bool
- Get a link associated with a value, or else return false if link does not apply.
- render() : array<string|int, mixed>|null
- Return rendered text (or null if nothing to render).
- renderCombineAlt() : string
- Render standard and alternative fields together.
- renderMulti() : array<string|int, mixed>
- Render multiple lines for a single set of data.
- renderRecordDriverTemplate() : string
- Render a record driver template.
- renderRecordHelper() : string
- Render using the record view helper.
- renderSimple() : string
- Simple rendering method.
- sortCallback() : int
- Sort callback for field specification.
Properties
$config
Config.
protected
Config
$config
$defaults
Default settings.
protected
array<string|int, mixed>
$defaults
= []
$driver
Record driver object.
protected
AbstractBase
$driver
= null
Methods
__construct()
Constructor
public
__construct([Config|null $config = null ]) : mixed
Parameters
- $config : Config|null = null
-
Config
Return values
mixed —__invoke()
Store a record driver object and return this object so that the appropriate data can be rendered.
public
__invoke([AbstractBase $driver = null ]) : RecordDataFormatter
Parameters
- $driver : AbstractBase = null
-
Record driver object.
Return values
RecordDataFormatter —getData()
Create formatted key/value data based on a record driver and field spec.
public
getData(array<string|int, mixed> ...$args) : array<string|int, mixed>
The first argument can be a descendant of RecordDriver. If omitted, then invoke this class with the desired driver. The second or first argument is an array containing formatting specifications.
Parameters
- $args : array<string|int, mixed>
-
Record driver object and/or formatting specifications.
Return values
array<string|int, mixed> —getDefaults()
Get default configuration.
public
getDefaults(string $key) : array<string|int, mixed>
Parameters
- $key : string
-
Key for configuration to look up.
Return values
array<string|int, mixed> —setDefaults()
Set default configuration.
public
setDefaults(string $key, array<string|int, mixed>|callable $values) : void
Parameters
- $key : string
-
Key for configuration to set.
- $values : array<string|int, mixed>|callable
-
Defaults to store (either an array, or a callable returning an array).
Return values
void —addOptions()
Add global and configured options to options of a field.
protected
addOptions(string $context, string $field, array<string|int, mixed> $options) : array<string|int, mixed>|null
Parameters
- $context : string
-
Context of the field.
- $field : string
-
Field
- $options : array<string|int, mixed>
-
Options of a field.
Return values
array<string|int, mixed>|null —allowValue()
Should we allow a value? (Always accepts non-empty values; for empty values, allows zero when configured to do so).
protected
allowValue(mixed $value, array<string|int, mixed> $options[, array<string|int, mixed> $ignoreCombineAlt = false ]) : bool
Parameters
- $value : mixed
-
Data to check for zero value.
- $options : array<string|int, mixed>
-
Rendering options.
- $ignoreCombineAlt : array<string|int, mixed> = false
-
If value should always be allowed when renderType is CombineAlt
Return values
bool —extractData()
Extract data (usually from the record driver).
protected
extractData(array<string|int, mixed> $options) : mixed
Parameters
- $options : array<string|int, mixed>
-
Incoming options
Return values
mixed —getLink()
Get a link associated with a value, or else return false if link does not apply.
protected
getLink(string $value, array<string|int, mixed> $options) : string|bool
Parameters
- $value : string
-
Value associated with link.
- $options : array<string|int, mixed>
-
Rendering options.
Return values
string|bool —render()
Return rendered text (or null if nothing to render).
protected
render(string $field, mixed $data, array<string|int, mixed> $options) : array<string|int, mixed>|null
Parameters
- $field : string
-
Field being rendered (i.e. default label)
- $data : mixed
-
Data to render
- $options : array<string|int, mixed>
-
Rendering options
Return values
array<string|int, mixed>|null —renderCombineAlt()
Render standard and alternative fields together.
protected
renderCombineAlt(mixed $data, array<string|int, mixed> $options) : string
Parameters
- $data : mixed
-
Data to render
- $options : array<string|int, mixed>
-
Rendering options.
Return values
string —renderMulti()
Render multiple lines for a single set of data.
protected
renderMulti(mixed $data, array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $data : mixed
-
Data to render
- $options : array<string|int, mixed>
-
Rendering options.
Return values
array<string|int, mixed> —renderRecordDriverTemplate()
Render a record driver template.
protected
renderRecordDriverTemplate(mixed $data, array<string|int, mixed> $options) : string
Parameters
- $data : mixed
-
Data to render
- $options : array<string|int, mixed>
-
Rendering options.
Return values
string —renderRecordHelper()
Render using the record view helper.
protected
renderRecordHelper(mixed $data, array<string|int, mixed> $options) : string
Parameters
- $data : mixed
-
Data to render
- $options : array<string|int, mixed>
-
Rendering options.
Return values
string —renderSimple()
Simple rendering method.
protected
renderSimple(mixed $data, array<string|int, mixed> $options) : string
Parameters
- $data : mixed
-
Data to render
- $options : array<string|int, mixed>
-
Rendering options.
Tags
Return values
string —sortCallback()
Sort callback for field specification.
protected
sortCallback(array<string|int, mixed> $a, array<string|int, mixed> $b) : int
Parameters
- $a : array<string|int, mixed>
-
First value to compare
- $b : array<string|int, mixed>
-
Second value to compare