mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-28 10:33:49 +00:00
[export] adding spreadsheet formatter
This commit is contained in:
@@ -116,8 +116,42 @@ interface ExportInterface extends ExportElementInterface
|
||||
/**
|
||||
* transform the results to viewable and understable string.
|
||||
*
|
||||
* The result should also contains an entry with a key _header which should
|
||||
* have, as value, a string for the header. See example in return declaration
|
||||
* The callable will have only one argument: the `value` to translate.
|
||||
*
|
||||
* The callable should also be able to return a key `_header`, which
|
||||
* will contains the header of the column.
|
||||
*
|
||||
* The string returned **must** be already translated if necessary,
|
||||
* **with an exception** for the string returned for `_header`.
|
||||
*
|
||||
* Example :
|
||||
*
|
||||
* ```
|
||||
* protected $translator;
|
||||
*
|
||||
* public function getLabels($key, array $values, $data)
|
||||
* {
|
||||
* return function($value) {
|
||||
* case $value
|
||||
* {
|
||||
* case '_header' :
|
||||
* return 'my header not translated';
|
||||
* case true:
|
||||
* return $this->translator->trans('true');
|
||||
* case false:
|
||||
* return $this->translator->trans('false');
|
||||
* default:
|
||||
* // this should not happens !
|
||||
* throw new \LogicException();
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* **Note:** Why each string must be translated with an exception for
|
||||
* the `_header` ? For performance reasons: most of the value will be number
|
||||
* which do not need to be translated, or value already translated in
|
||||
* database. But the header must be, in every case, translated.
|
||||
*
|
||||
*
|
||||
* @param string $key The column key, as added in the query
|
||||
* @param mixed[] $values The values from the result. if there are duplicates, those might be given twice. Example: array('FR', 'BE', 'CZ', 'FR', 'BE', 'FR')
|
||||
|
Reference in New Issue
Block a user