Skip to content

Commit

Permalink
Check for web request before accessing post()
Browse files Browse the repository at this point in the history
These small modifications allow the use of the extension in console
context, specifically using it in a background job.
  • Loading branch information
Lorenzo Milesi committed Apr 23, 2022
1 parent ffae06b commit 2f3b58d
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/ExportMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -860,16 +860,23 @@ protected function initSettings()
}
$this->_columnSelectorEnabled = $this->showColumnSelector && $this->asDropdown;
$request = Yii::$app->request;
$this->_triggerDownload = $request->post($this->exportRequestParam, $this->triggerDownload);
$this->_exportType = $request->post($this->exportTypeParam, $this->exportType);
if ($request instanceof \yii\web\Request) {
$this->_triggerDownload = $request->post($this->exportRequestParam, $this->triggerDownload);
$this->_exportType = $request->post($this->exportTypeParam, $this->exportType);
} else {
$this->_triggerDownload = $this->triggerDownload;
$this->_exportType = $this->exportType;
}
if (!$this->stream) {
$this->target = self::TARGET_SELF;
}
if ($this->_triggerDownload) {
if ($this->stream) {
Yii::$app->controller->layout = false;
}
$this->_columnSelectorEnabled = $request->post($this->colSelFlagParam, $this->_columnSelectorEnabled);
$this->_columnSelectorEnabled = $request instanceof \yii\web\Request ?
$request->post($this->colSelFlagParam, $this->_columnSelectorEnabled) :
$this->_columnSelectorEnabled;
$this->initSelectedColumns();
}
if ($this->dynagrid) {
Expand Down

0 comments on commit 2f3b58d

Please sign in to comment.