Skip to content

Commit

Permalink
Merge pull request #1 from Ezyt/master
Browse files Browse the repository at this point in the history
fix for console
  • Loading branch information
AxelPAL committed Apr 12, 2016
2 parents 693ce84 + 6051c11 commit 28cf8ce
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions FileModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use yii\base\Module;
use yii\helpers\FileHelper;
use yii\i18n\PhpMessageSource;
use yii\web\Controller;

class FileModule extends Module
{
Expand Down Expand Up @@ -81,13 +82,17 @@ public function getFilesDirPath($fileHash, $useStorePath = true)

public function getUserDirPath()
{
\Yii::$app->session->open();
if(\Yii::$app->controller instanceof Controller) {
\Yii::$app->session->open();
$sessionId = \Yii::$app->session->id;
\Yii::$app->session->close();
} else {
$sessionId = 'console';
}

$userDirPath = $this->getTempPath() . DIRECTORY_SEPARATOR . \Yii::$app->session->id;
$userDirPath = $this->getTempPath() . DIRECTORY_SEPARATOR . $sessionId;
FileHelper::createDirectory($userDirPath);

\Yii::$app->session->close();

return $userDirPath . DIRECTORY_SEPARATOR;
}

Expand Down

0 comments on commit 28cf8ce

Please sign in to comment.