public function onBuildHeadCSV(array &$head, mixed $handler) : void

Fires while constructing the head of the CSV table.


Description

Trigger hook to allow the plugins to manipulate the heading row of the CSV file. Here it is possible to attach new columns, detach existing columns and reorder them.

Notice that the same changes must be applied to the body of the CSV, otherwise the columns might result shifted.


Parameters

&$head

(array)  An array of columns.

$handler

(VAPOrderExportDriverCsv)  The instance used to export the records.

Return Value

None.


Example

/**
 * Trigger event to allow the plugins to manipulate the heading
 * row of the CSV file. Here it is possible to attach new columns,
 * detach existing columns and reorder them. Notice that the same
 * changes must be applied to the body of the CSV, otherwise the
 * columns might result shifted.
 *
 * @param   mixed  &$head    The CSV head array.
 * @param   mixed  $handler  The current handler instance.
 *
 * @return  void
 */
public function onBuildHeadCSV(&$head, $handler)
{
    // include the user ID as a new column
    $head['id_user'] = 'User ID';

    // get rid of order key column
    unset($head['sid']);
}

Changelog

VersionDescription
1.7 Introduced.
Last Update: 2021-10-08 10:03
Helpful?