-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
Copy pathForm.php
79 lines (73 loc) · 2.33 KB
/
Form.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Backend\Block\System\Cache;
/**
* Cache management form page
*/
class Form extends \Magento\Backend\Block\Widget\Form\Generic
{
/**
* @var \Magento\Framework\App\Cache\TypeListInterface
*/
protected $cacheTypeList;
/**
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Data\FormFactory $formFactory
* @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Data\FormFactory $formFactory,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
array $data = []
) {
$this->cacheTypeList = $cacheTypeList;
parent::__construct($context, $registry, $formFactory, $data);
}
/**
* Initialize cache management form
*
* @return $this
*/
public function initForm()
{
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$fieldset = $form->addFieldset('cache_enable', ['legend' => __('Cache Control')]);
$fieldset->addField(
'all_cache',
'select',
[
'name' => 'all_cache',
'label' => '<strong>' . __('All Cache') . '</strong>',
'value' => 1,
'options' => [
'' => __('No change'),
'refresh' => __('Refresh'),
'disable' => __('Disable'),
'enable' => __('Enable'),
]
]
);
foreach ($this->cacheTypeList->getTypeLabels() as $type => $label) {
$fieldset->addField(
'enable_' . $type,
'checkbox',
[
'name' => 'enable[' . $type . ']',
'label' => __($label),
'value' => 1,
'checked' => (int)$this->_cacheState->isEnabled($type)
]
);
}
$this->setForm($form);
return $this;
}
}