Skip to content

Commit

Permalink
Merge pull request #261 from PowerSync/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
eermolaev authored Oct 22, 2020
2 parents fbd0897 + fbfe379 commit 4b85e9d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
38 changes: 28 additions & 10 deletions Controller/Adminhtml/System/Log/Download.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
<?php
namespace TNW\Salesforce\Controller\Adminhtml\System\Log;

use Exception;
use InvalidArgumentException;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\Response\Http\FileFactory;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Controller\ResultInterface;
use Magento\Framework\Exception\NotFoundException;
use TNW\Salesforce\Model\Config;

class Download extends \Magento\Backend\App\Action
class Download extends Action
{
/**
* @var \Magento\Framework\App\Response\Http\FileFactory
* @var FileFactory
*/
protected $fileFactory;

/** @var Config */
protected $salesforceConfig;

public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\App\Response\Http\FileFactory $fileFactory
Context $context,
FileFactory $fileFactory,
Config $salesforceConfig
) {
$this->fileFactory = $fileFactory;
$this->salesforceConfig = $salesforceConfig;
parent::__construct($context);
}

/**
* Dispatch request
*
* @return \Magento\Framework\Controller\ResultInterface|\Magento\Framework\App\ResponseInterface
* @throws \Magento\Framework\Exception\NotFoundException
* @throws \InvalidArgumentException
* @throws \Exception
* @return ResultInterface|ResponseInterface
* @throws NotFoundException
* @throws InvalidArgumentException
* @throws Exception
*/
public function execute()
{
$baseDay = $this->salesforceConfig->logBaseDay();

$filenamePath = sprintf('log/sforce/%d_%d_%d.log', date('Y'), $baseDay, floor((date('z') + 1) / $baseDay));

return $this->fileFactory->create('sforce.log', [
'type' => 'filename',
'value' => 'log/sforce.log'
'value' => $filenamePath
], DirectoryList::VAR_DIR);
}
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"gpl-3.0"
],
"type": "magento2-module",
"version": "2.6.38",
"version": "2.6.39",
"autoload": {
"files": [
"registration.php"
Expand Down

0 comments on commit 4b85e9d

Please sign in to comment.