1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tkotosz\CommandScheduler\Block\Adminhtml\Schedule\Create\From\Tab; |
4
|
|
|
|
5
|
|
|
use Magento\Backend\Block\Widget\Form\Generic; |
|
|
|
|
6
|
|
|
use Magento\Backend\Block\Widget\Tab\TabInterface; |
|
|
|
|
7
|
|
|
use Tkotosz\CommandScheduler\Model\AllowedCommandsContainer; |
8
|
|
|
|
9
|
|
|
class Settings extends Generic implements TabInterface |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var AllowedCommandsContainer |
13
|
|
|
*/ |
14
|
|
|
private $allowedCommandsContainer; |
15
|
|
|
|
16
|
|
|
public function __construct( |
17
|
|
|
\Magento\Backend\Block\Template\Context $context, |
|
|
|
|
18
|
|
|
\Magento\Framework\Registry $registry, |
19
|
|
|
\Magento\Framework\Data\FormFactory $formFactory, |
20
|
|
|
AllowedCommandsContainer $allowedCommandsContainer, |
21
|
|
|
array $data = [] |
22
|
|
|
) { |
23
|
|
|
$this->allowedCommandsContainer = $allowedCommandsContainer; |
24
|
|
|
|
25
|
|
|
parent::__construct($context, $registry, $formFactory, $data); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @return void |
30
|
|
|
*/ |
31
|
|
|
protected function _construct() |
32
|
|
|
{ |
33
|
|
|
parent::_construct(); |
34
|
|
|
$this->setActive(true); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Prepare label for tab |
39
|
|
|
* |
40
|
|
|
* @return \Magento\Framework\Phrase |
41
|
|
|
*/ |
42
|
|
|
public function getTabLabel() |
43
|
|
|
{ |
44
|
|
|
return __('Settings'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Prepare title for tab |
49
|
|
|
* |
50
|
|
|
* @return \Magento\Framework\Phrase |
51
|
|
|
*/ |
52
|
|
|
public function getTabTitle() |
53
|
|
|
{ |
54
|
|
|
return __('Settings'); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Returns status flag about this tab can be showen or not |
59
|
|
|
* |
60
|
|
|
* @return true |
61
|
|
|
*/ |
62
|
|
|
public function canShowTab() |
63
|
|
|
{ |
64
|
|
|
return $this->getFormData()->getData('command') === null; |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Returns status flag about this tab hidden or not |
69
|
|
|
* |
70
|
|
|
* @return true |
71
|
|
|
*/ |
72
|
|
|
public function isHidden() |
73
|
|
|
{ |
74
|
|
|
return false; |
|
|
|
|
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getFormData() |
78
|
|
|
{ |
79
|
|
|
return $this->_coreRegistry->registry('tkotosz_command_scheduler_data_container'); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Prepare form before rendering HTML |
84
|
|
|
* |
85
|
|
|
* @return $this |
86
|
|
|
*/ |
87
|
|
|
protected function _prepareForm() |
88
|
|
|
{ |
89
|
|
|
/** @var \Magento\Framework\Data\Form $form */ |
90
|
|
|
$form = $this->_formFactory->create( |
91
|
|
|
['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']] |
92
|
|
|
); |
93
|
|
|
|
94
|
|
|
$fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Settings')]); |
95
|
|
|
|
96
|
|
|
$this->_addElementTypes($fieldset); |
97
|
|
|
|
98
|
|
|
$fieldset->addField( |
99
|
|
|
'command', |
100
|
|
|
'select', |
101
|
|
|
[ |
102
|
|
|
'name' => 'command', |
103
|
|
|
'label' => __('Command'), |
104
|
|
|
'title' => __('Command'), |
105
|
|
|
'required' => true, |
106
|
|
|
'values' => $this->getTypesOptionsArray() |
107
|
|
|
] |
108
|
|
|
); |
109
|
|
|
|
110
|
|
|
$continueButton = $this->getLayout()->createBlock( |
111
|
|
|
\Magento\Backend\Block\Widget\Button::class |
|
|
|
|
112
|
|
|
)->setData( |
113
|
|
|
[ |
114
|
|
|
'label' => __('Continue'), |
115
|
|
|
'onclick' => "setSettings('" . $this->getContinueUrl() . "', 'command')", |
116
|
|
|
'class' => 'save', |
117
|
|
|
] |
118
|
|
|
); |
119
|
|
|
$fieldset->addField('continue_button', 'note', ['text' => $continueButton->toHtml()]); |
120
|
|
|
|
121
|
|
|
$this->setForm($form); |
122
|
|
|
|
123
|
|
|
return parent::_prepareForm(); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* Return url for continue button |
128
|
|
|
* |
129
|
|
|
* @return string |
130
|
|
|
*/ |
131
|
|
|
public function getContinueUrl() |
132
|
|
|
{ |
133
|
|
|
return $this->getUrl( |
134
|
|
|
'tkotosz_commandscheduler/schedule/create', |
135
|
|
|
[ |
136
|
|
|
'_current' => true, |
137
|
|
|
'command' => '<%- data.command %>', |
138
|
|
|
'_escape_params' => false |
139
|
|
|
] |
140
|
|
|
); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* @return array |
145
|
|
|
*/ |
146
|
|
|
public function getTypesOptionsArray() |
147
|
|
|
{ |
148
|
|
|
$options = [['value' => '', 'label' => __('-- Please Select --')]]; |
149
|
|
|
|
150
|
|
|
foreach ($this->allowedCommandsContainer->getAllowedCommands() as $label => $commandName) { |
151
|
|
|
$options[] = ['value' => $commandName, 'label' => $label]; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
return $options; |
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
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