maj doc
This commit is contained in:
parent
6bcd8d4cf6
commit
0945a86763
@ -122,20 +122,6 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||||||
return $this->index;
|
return $this->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function _sendContentType(): void;
|
|
||||||
|
|
||||||
protected bool $sentHeaders = false;
|
|
||||||
|
|
||||||
function sendHeaders(): void {
|
|
||||||
if ($this->sentHeaders) return;
|
|
||||||
$this->_sendContentType();
|
|
||||||
$output = $this->output;
|
|
||||||
if ($output !== null) {
|
|
||||||
http::download_as(path::filename($output));
|
|
||||||
}
|
|
||||||
$this->sentHeaders = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function _build(?iterable $rows=null): void {
|
protected function _build(?iterable $rows=null): void {
|
||||||
$this->writeAll($rows);
|
$this->writeAll($rows);
|
||||||
$this->writeHeaders();
|
$this->writeHeaders();
|
||||||
@ -158,6 +144,20 @@ abstract class AbstractBuilder extends TempStream implements IBuilder {
|
|||||||
return $ok;
|
return $ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract protected function _sendContentType(): void;
|
||||||
|
|
||||||
|
protected bool $sentHeaders = false;
|
||||||
|
|
||||||
|
function sendHeaders(): void {
|
||||||
|
if ($this->sentHeaders) return;
|
||||||
|
$this->_sendContentType();
|
||||||
|
$output = $this->output;
|
||||||
|
if ($output !== null) {
|
||||||
|
http::download_as(path::filename($output));
|
||||||
|
}
|
||||||
|
$this->sentHeaders = true;
|
||||||
|
}
|
||||||
|
|
||||||
function sendFile(?iterable $rows=null): int {
|
function sendFile(?iterable $rows=null): int {
|
||||||
if (!$this->built) {
|
if (!$this->built) {
|
||||||
$this->_build($rows);
|
$this->_build($rows);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace nulib\file\tab;
|
namespace nulib\file\tab;
|
||||||
|
|
||||||
|
use nulib\file\IWriter;
|
||||||
|
|
||||||
interface IBuilder extends \nulib\file\IReader {
|
interface IBuilder extends \nulib\file\IReader {
|
||||||
function writeHeaders(?array $headers=null): void;
|
function writeHeaders(?array $headers=null): void;
|
||||||
|
|
||||||
@ -13,7 +15,18 @@ interface IBuilder extends \nulib\file\IReader {
|
|||||||
*/
|
*/
|
||||||
function getCount(): int;
|
function getCount(): int;
|
||||||
|
|
||||||
|
/** préparer le fichier (sans l'envoyer) */
|
||||||
|
function build(?iterable $rows=null, bool $close=true): bool;
|
||||||
|
|
||||||
|
/** enregistrer le fichier préparé avec {@link build()} */
|
||||||
|
function copyTo(IWriter $dest, bool $closeWriter=false, bool $closeReader=true): void;
|
||||||
|
|
||||||
|
/** envoyer les en-têtes */
|
||||||
function sendHeaders(): void;
|
function sendHeaders(): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* envoyer le fichier pour téléchargement (la méthode {@link sendHeaders()}
|
||||||
|
* est automatiquement appelée le cas échéant
|
||||||
|
*/
|
||||||
function sendFile(?iterable $rows=null): int;
|
function sendFile(?iterable $rows=null): int;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user