suivi index du row
This commit is contained in:
parent
22c8067c8f
commit
4c138708ed
|
@ -33,6 +33,7 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||
$rows = $params["rows"] ?? null;
|
||||
if (is_callable($rows)) $rows = $rows();
|
||||
$this->rows = $rows;
|
||||
$this->index = 0;
|
||||
$cookFunc = $params["cook_func"] ?? null;
|
||||
$cookCtx = $cookArgs = null;
|
||||
if ($cookFunc !== null) {
|
||||
|
@ -55,6 +56,8 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||
|
||||
protected ?iterable $rows;
|
||||
|
||||
protected int $index;
|
||||
|
||||
protected ?string $output;
|
||||
|
||||
protected ?array $cookCtx;
|
||||
|
@ -89,14 +92,14 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||
$row = nur_func::_call($this->cookCtx, $args);
|
||||
}
|
||||
if ($row !== null) {
|
||||
foreach ($row as &$value) {
|
||||
foreach ($row as &$col) {
|
||||
# formatter les dates
|
||||
if ($value instanceof DateTime) {
|
||||
$value = $value->format();
|
||||
} elseif ($value instanceof DateTimeInterface) {
|
||||
$value = DateTime::with($value)->format();
|
||||
if ($col instanceof DateTime) {
|
||||
$col = $col->format();
|
||||
} elseif ($col instanceof DateTimeInterface) {
|
||||
$col = DateTime::with($col)->format();
|
||||
}
|
||||
}; unset($value);
|
||||
}; unset($col);
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
@ -106,6 +109,7 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||
if ($row === null) return;
|
||||
$this->writeHeaders(array_keys($row));
|
||||
$this->_write($row, $colsStyle, $rowStyle);
|
||||
$this->index++;
|
||||
}
|
||||
|
||||
function writeAll(?iterable $rows=null, ?array $rowStyle=null): void {
|
||||
|
|
Loading…
Reference in New Issue