1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tkotosz\CommandScheduler\Controller\Adminhtml\Schedule; |
4
|
|
|
|
5
|
|
|
use Tkotosz\CommandScheduler\Controller\Adminhtml\Schedule; |
6
|
|
|
use Tkotosz\CommandScheduler\Request\Factory\CreateCommandScheduleRequestFactory; |
7
|
|
|
use Tkotosz\CommandScheduler\Request\Processor\CreateCommandScheduleRequestProcessor; |
8
|
|
|
use Magento\Backend\App\Action\Context; |
|
|
|
|
9
|
|
|
use Magento\Framework\Controller\ResultInterface; |
10
|
|
|
use Psr\Log\LoggerInterface; |
11
|
|
|
|
12
|
|
|
class Save extends Schedule |
13
|
|
|
{ |
14
|
|
|
const SUCCESS_PATH = 'tkotosz_commandscheduler/schedule/index'; |
15
|
|
|
const ERROR_PATH = 'tkotosz_commandscheduler/schedule/create'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var LoggerInterface |
19
|
|
|
*/ |
20
|
|
|
private $logger; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var CreateCommandScheduleRequestFactory |
24
|
|
|
*/ |
25
|
|
|
private $requestFactory; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var CreateCommandScheduleRequestProcessor |
29
|
|
|
*/ |
30
|
|
|
private $requestProcessor; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param Context $context |
34
|
|
|
* @param LoggerInterface $logger |
35
|
|
|
* @param CreateCommandScheduleRequestFactory $requestFactory |
36
|
|
|
* @param CreateCommandScheduleRequestProcessor $requestProcessor |
37
|
|
|
*/ |
38
|
|
|
public function __construct( |
39
|
|
|
Context $context, |
40
|
|
|
LoggerInterface $logger, |
41
|
|
|
CreateCommandScheduleRequestFactory $requestFactory, |
42
|
|
|
CreateCommandScheduleRequestProcessor $requestProcessor |
43
|
|
|
) { |
44
|
|
|
parent::__construct($context); |
45
|
|
|
|
46
|
|
|
$this->logger = $logger; |
47
|
|
|
$this->requestFactory = $requestFactory; |
48
|
|
|
$this->requestProcessor = $requestProcessor; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Execute action based on request and return result |
53
|
|
|
* |
54
|
|
|
* @return ResultInterface |
55
|
|
|
*/ |
56
|
|
|
public function execute() |
57
|
|
|
{ |
58
|
|
|
try { |
59
|
|
|
$request = $this->requestFactory->createFromHttpRequest($this->getRequest()); |
60
|
|
|
$this->requestProcessor->process($request); |
61
|
|
|
$this->messageManager->addSuccessMessage('Command scheduled.'); |
62
|
|
|
$path = self::SUCCESS_PATH; |
63
|
|
|
} catch (\Exception $e) { |
64
|
|
|
$this->logger->critical($e); |
65
|
|
|
$this->_getSession()->setScheduleFormData($this->getRequest()->getParams()); |
66
|
|
|
$this->messageManager->addErrorMessage('An error occurred whilst scheduling the command: ' . $e->getMessage()); |
67
|
|
|
$path = self::ERROR_PATH; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
return $this->resultRedirectFactory->create()->setPath($path); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths