$name
$name : string
The name for this helper, used when you want to define a global custom callback for a given field
The header helper allows you to render the content of the header for a given field in a CSV table. When defining a custom callback for this helper, use the following callback parameters:
$csvCell->getContentRenderer()->assign( 'my_model:my_field', function ($helper, array $rowData, $rowIndex, $columnIndex) { // Param $helper is a reference to this instance of the Header helper // Param $rowData is an associative array representing all the data available to render this table row. // Param $rowIndex is a zero-based index of the current row being rendered // Param $columnIndex is a zero-based index of the current column being rendered return 'something'; } );
assign(mixed $assignments, callable $callable = null) : \Dewdrop\Fields\Helper\HelperAbstract
Assign one more custom per-instance callbacks for this helper. If the $arguments param is an array, this method expects that the keys will be field IDs and the values will be callables, assigning custom callbacks for multiple fields in one call. If, however, $assignments is a string or a FieldInterface object, a single custom callback assignment will be made.
mixed | $assignments | |
callable | $callable |
getFieldAssignment(\Dewdrop\Fields\FieldInterface $field) : callable
Get the callback that will be used for the given FieldInterface object.
\Dewdrop\Fields\FieldInterface | $field |
detectCallableForField(\Dewdrop\Fields\FieldInterface $field) : string|false
If no custom callback is defined for a field, it will fall back to this method to find a suitable callback. In the case of the Content helper, we only provide a fall back for DB-based fields. Custom fields will have to define a callback in order to function properly.
If no callback candidate is found, just return false from this method, which will be detected by getFieldAssignment(), causing execution to halt.
\Dewdrop\Fields\FieldInterface | $field |
setNullContentPlaceholder(string $nullContentPlaceholder) : \Dewdrop\Fields\Helper\CsvCell\Content
Set the content that should be returned if a field's callback returns no output.
string | $nullContentPlaceholder |
setDateFormat(string $dateFormat) : \Dewdrop\Fields\Helper\CsvCell\Content
Set an alternative format for date rendering. Uses PHP's date() syntax.
string | $dateFormat |
setTimeFormat(string $timeFormat) : \Dewdrop\Fields\Helper\TableCell\Content
Set an alternative format for time rendering. Uses PHP's date() syntax.
string | $timeFormat |
render(\Dewdrop\Fields\FieldInterface $field, array $rowData, integer $rowIndex, integer $columnIndex) : string
Render the cell's content for the supplied field.
\Dewdrop\Fields\FieldInterface | $field | |
array | $rowData | |
integer | $rowIndex | |
integer | $columnIndex |
assignCallbackByColumnPosition(integer $columnIndex, callable $callback) : \Dewdrop\Fields\Helper\CsvCell\Content
Assign a callback based upon the column position currently being displayed. This can be useful, for example, if you'd like to display something specific in a particular column of your table automatically.
You can wrap the callback that would have been used by calling the getFieldAssignment() method with the appropriate field object.
integer | $columnIndex | |
callable | $callback |
wrapCallable(callable $callable, \Dewdrop\Fields\FieldInterface $field = null) : callable
Wrap a field's callback to ensure that a reference to the helper is always supplied as the first argument to the callback.
callable | $callable | |
\Dewdrop\Fields\FieldInterface | $field |
renderDbText(\Dewdrop\Db\Field $field, array $rowData) : string
A fall back method for basic DB fields. Just returns the text for the field in your row's data.
\Dewdrop\Db\Field | $field | |
array | $rowData |
renderDbReference(\Dewdrop\Db\Field $field, array $rowData) : string
A fall back method for DB reference fields. For foreign keys, we trim the "_id" off the end and look for the resulting field in the result set.
For example, if you foreign key is "state_id", we look for a result set key of "state" and render that value for the field.
\Dewdrop\Db\Field | $field | |
array | $rowData |
renderDbBoolean(\Dewdrop\Db\Field $field, array $rowData) : string
Render cell content for a boolean database field.
\Dewdrop\Db\Field | $field | |
array | $rowData |
renderDbDate(\Dewdrop\Db\Field $field, array $rowData) : string
A fall back method for date fields. Will convert the DB value to a Unix timestamp and then format it with PHP's date() function. (How retro!) You can customize the format with setDateFormat().
\Dewdrop\Db\Field | $field | |
array | $rowData |
renderDbTimestamp(\Dewdrop\Db\Field $field, array $rowData) : string
A fall back method for timestamp fields. Will convert the DB value to a Unix timestamp and then format it with PHP's date() function. (How retro!) You can customize the format with setDateFormat().
\Dewdrop\Db\Field | $field | |
array | $rowData |