\Dewdrop\Fields\Helper\CsvCellHeader

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, using the following callback parameters:

$csvCell->getHeaderRenderer()->assign(
    'my_model:my_field',
    function ($helper, $field) {
        // Param $helper is a reference to this instance of the Header helper
        // Param $field is your Field object, so you can get the label, etc.

        return 'something';
    }
);

NOTE: You do not have to supply a callback for this helper for any fields. By default, this helper will just use the field's label for the header content, so you only need to supply a custom callback if the field label is not appropriate.

Summary

Methods
Properties
Constants
matchesName()
assign()
getFieldAssignment()
hasValidName()
detectCallableForField()
render()
No public properties found
No constants found
wrapCallable()
$name
N/A
No private methods found
$assignments
N/A

Properties

$name

$name : string

The name for this helper, used when you want to define a global custom callback for a given field

Type

string

$assignments

$assignments : array

Any per-instance callback assignments for this helper. This array will have field IDs as the keys and callables as the values.

Type

array

Methods

matchesName()

matchesName(string  $name) : boolean

Check to see if the supplied input matches this helper's name (case-insensitive).

Parameters

string $name

Returns

boolean

assign()

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.

Parameters

mixed $assignments
callable $callable

Returns

\Dewdrop\Fields\Helper\HelperAbstract

getFieldAssignment()

getFieldAssignment(\Dewdrop\Fields\FieldInterface  $field) : callable

Get the callback that will be used for the given FieldInterface object.

Parameters

\Dewdrop\Fields\FieldInterface $field

Throws

\Dewdrop\Fields\Exception\HelperCallableNotAvailableForField

Returns

callable

hasValidName()

hasValidName() : boolean

Ensure the helper has a valid $name value. If not, throw an exception.

All helpers must have a name defined so that global custom callbacks can be added to fields.

Throws

\Dewdrop\Fields\Exception\HelperMustHaveName

Returns

boolean

detectCallableForField()

detectCallableForField(\Dewdrop\Fields\FieldInterface  $field) : callable

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 Header helper, we fall back to all fields just returning their labels.

If no callback candidate is found, just return false from this method, which will be detected by getFieldAssignment(), causing execution to halt.

Parameters

\Dewdrop\Fields\FieldInterface $field

Returns

callable

render()

render(\Dewdrop\Fields\FieldInterface  $field) : string

Render the header content for the supplied field.

Parameters

\Dewdrop\Fields\FieldInterface $field

Returns

string

wrapCallable()

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.

Parameters

callable $callable
\Dewdrop\Fields\FieldInterface $field

Returns

callable