|
@@ -12,13 +12,18 @@ trait HasExporter
|
|
|
/**
|
|
/**
|
|
|
* @var Exporter
|
|
* @var Exporter
|
|
|
*/
|
|
*/
|
|
|
- protected $__exporter;
|
|
|
|
|
|
|
+ protected $exporter;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @var bool
|
|
* @var bool
|
|
|
*/
|
|
*/
|
|
|
protected $enableExporter = false;
|
|
protected $enableExporter = false;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @var bool
|
|
|
|
|
+ */
|
|
|
|
|
+ protected $exported = false;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Set exporter driver for Grid to export.
|
|
* Set exporter driver for Grid to export.
|
|
|
*
|
|
*
|
|
@@ -53,12 +58,21 @@ trait HasExporter
|
|
|
*
|
|
*
|
|
|
* @return mixed
|
|
* @return mixed
|
|
|
*/
|
|
*/
|
|
|
- protected function handleExportRequest($forceExport = false)
|
|
|
|
|
|
|
+ public function handleExportRequest($forceExport = false)
|
|
|
{
|
|
{
|
|
|
- if (! $scope = request($this->exporter()->queryName())) {
|
|
|
|
|
|
|
+ if (
|
|
|
|
|
+ $this->exported
|
|
|
|
|
+ || (
|
|
|
|
|
+ (! $this->allowExporter()
|
|
|
|
|
+ || ! $scope = request($this->exporter()->queryName()))
|
|
|
|
|
+ && ! $forceExport
|
|
|
|
|
+ )
|
|
|
|
|
+ ) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ $this->exported = true;
|
|
|
|
|
+
|
|
|
$this->callBuilder();
|
|
$this->callBuilder();
|
|
|
|
|
|
|
|
// clear output buffer.
|
|
// clear output buffer.
|
|
@@ -67,6 +81,7 @@ trait HasExporter
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if ($forceExport || $this->allowExporter()) {
|
|
if ($forceExport || $this->allowExporter()) {
|
|
|
|
|
+
|
|
|
return $this->resolveExportDriver($scope)->export();
|
|
return $this->resolveExportDriver($scope)->export();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -76,7 +91,13 @@ trait HasExporter
|
|
|
*/
|
|
*/
|
|
|
public function exporter()
|
|
public function exporter()
|
|
|
{
|
|
{
|
|
|
- return $this->__exporter ?: ($this->__exporter = new Exporter($this));
|
|
|
|
|
|
|
+// if (! $this->exporter) {
|
|
|
|
|
+// $this->exporter = new Exporter($this);
|
|
|
|
|
+//
|
|
|
|
|
+// $this->setExporterQueryName();
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
|
|
+ return $this->exporter ?: ($this->exporter = new Exporter($this));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -86,11 +107,11 @@ trait HasExporter
|
|
|
*/
|
|
*/
|
|
|
protected function setExporterQueryName(string $name = null)
|
|
protected function setExporterQueryName(string $name = null)
|
|
|
{
|
|
{
|
|
|
- if (! $this->allowExporter()) {
|
|
|
|
|
|
|
+ if (! $this->exporter) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $this->exporter()->setQueryName(($name ?: $this->getName()).'_export_');
|
|
|
|
|
|
|
+ $this->exporter->setQueryName(($name ?: $this->getName()).'_export_');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|