1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Firegento\DevDashboard\Block\Adminhtml\Dashboard; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @method Configuration setTitle(string $title) |
7
|
|
|
*/ |
8
|
|
|
class Configuration extends \Magento\Config\Block\System\Config\Edit |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @var mixed |
13
|
|
|
*/ |
14
|
|
|
public $originalParams; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Configuration constructor. |
18
|
|
|
* |
19
|
|
|
* @param \Magento\Backend\Block\Template\Context $context |
20
|
|
|
* @param \Magento\Config\Model\Config\Structure $configStructure |
21
|
|
|
* @param array $data |
22
|
|
|
*/ |
23
|
|
|
public function __construct( |
24
|
|
|
\Magento\Backend\Block\Template\Context $context, |
25
|
|
|
\Magento\Config\Model\Config\Structure $configStructure, |
26
|
|
|
array $data = [] |
27
|
|
|
) { |
28
|
|
|
parent::__construct($context, $configStructure, $data); |
29
|
|
|
|
30
|
|
|
$this->_prepareRequestParams(); |
31
|
|
|
$this->setTitle((string) __('Developer configurations')); |
32
|
|
|
$this->_resetRequestParams(); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @return $this |
37
|
|
|
*/ |
38
|
|
|
public function _prepareLayout() |
39
|
|
|
{ |
40
|
|
|
$this->_prepareRequestParams(); |
41
|
|
|
parent::_prepareLayout(); |
42
|
|
|
|
43
|
|
|
return $this; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* |
48
|
|
|
*/ |
49
|
|
|
public function _prepareRequestParams() |
50
|
|
|
{ |
51
|
|
|
$this->originalParams = $this->getRequest()->getParam('section'); |
52
|
|
|
$this->getRequest()->setParams(['section' => 'dev']); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* |
57
|
|
|
*/ |
58
|
|
|
public function _resetRequestParams() |
59
|
|
|
{ |
60
|
|
|
$this->getRequest()->setParams(['section' => $this->originalParams]); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public function getSaveUrl() |
67
|
|
|
{ |
68
|
|
|
return $this->getUrl('adminhtml/system_config/save', ['section' => 'dev']); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
protected function _toHtml() |
72
|
|
|
{ |
73
|
|
|
$html = parent::_toHtml(); |
74
|
|
|
if (strpos($html, 'class="section-config"') === false) { |
75
|
|
|
return 'Developer configuration is only available in developer mode'; |
76
|
|
|
} |
77
|
|
|
return $html; |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|