possiblité de spécifier le style des lignes
This commit is contained in:
parent
3958b8f11d
commit
5c8f26ed16
|
@ -17,7 +17,7 @@ class CsvBuilder extends AbstractBuilder {
|
|||
parent::__construct($output, $params);
|
||||
}
|
||||
|
||||
protected function _write(array $row): void {
|
||||
protected function _write(array $row, ?array $rowStyle=null): void {
|
||||
$this->fputcsv($row);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
protected abstract function _write(array $row): void;
|
||||
protected abstract function _write(array $row, ?array $rowStyle=null): void;
|
||||
|
||||
protected bool $wroteHeaders = false;
|
||||
|
||||
|
@ -101,14 +101,14 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||
return $row;
|
||||
}
|
||||
|
||||
function write(?array $row): void {
|
||||
function write(?array $row, ?array $rowStyle=null): void {
|
||||
$row = $this->cookRow($row);
|
||||
if ($row === null) return;
|
||||
$this->writeHeaders(array_keys($row));
|
||||
$this->_write($row);
|
||||
$this->_write($row, $rowStyle);
|
||||
}
|
||||
|
||||
function writeAll(?iterable $rows=null): void {
|
||||
function writeAll(?iterable $rows=null, ?array $rowStyle=null): void {
|
||||
$unsetRows = false;
|
||||
if ($rows === null) {
|
||||
$rows = $this->rows;
|
||||
|
@ -116,7 +116,7 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||
}
|
||||
if ($rows !== null) {
|
||||
foreach ($rows as $row) {
|
||||
$this->write(cl::with($row));
|
||||
$this->write(cl::with($row), $rowStyle);
|
||||
}
|
||||
}
|
||||
if ($unsetRows) $this->rows = null;
|
||||
|
|
Loading…
Reference in New Issue