Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Group.php
Go to the documentation of this file.
1 <?php
8 
13 class Group extends AbstractComposite
14 {
21 
26  protected $_dependencyMapper;
27 
35  public function __construct(
37  \Magento\Framework\Module\Manager $moduleManager,
38  \Magento\Config\Model\Config\Structure\Element\Iterator\Field $childrenIterator,
39  \Magento\Config\Model\Config\BackendClone\Factory $cloneModelFactory,
40  \Magento\Config\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper
41  ) {
42  parent::__construct($storeManager, $moduleManager, $childrenIterator);
43  $this->_cloneModelFactory = $cloneModelFactory;
44  $this->_dependencyMapper = $dependencyMapper;
45  }
46 
52  public function shouldCloneFields()
53  {
54  return isset($this->_data['clone_fields']) && !empty($this->_data['clone_fields']);
55  }
56 
63  public function getCloneModel()
64  {
65  if (!isset($this->_data['clone_model']) || !$this->_data['clone_model']) {
66  throw new \Magento\Framework\Exception\LocalizedException(
67  __('Config form fieldset clone model required to be able to clone fields')
68  );
69  }
70  return $this->_cloneModelFactory->create($this->_data['clone_model']);
71  }
72 
79  public function populateFieldset(\Magento\Framework\Data\Form\Element\Fieldset $fieldset)
80  {
81  $originalData = [];
82  foreach ($this->_data as $key => $value) {
83  if (!is_array($value)) {
84  $originalData[$key] = $value;
85  }
86  }
87  $fieldset->setOriginalData($originalData);
88  }
89 
95  public function isExpanded()
96  {
97  return (bool)(isset($this->_data['expanded']) ? (int)$this->_data['expanded'] : false);
98  }
99 
105  public function getFieldsetCss()
106  {
107  return array_key_exists('fieldset_css', $this->_data) ? $this->_data['fieldset_css'] : '';
108  }
109 
116  public function getDependencies($storeCode)
117  {
118  $dependencies = [];
119  if (false == isset($this->_data['depends']['fields'])) {
120  return $dependencies;
121  }
122 
123  $dependencies = $this->_dependencyMapper->getDependencies($this->_data['depends']['fields'], $storeCode);
124  return $dependencies;
125  }
126 }
$storeManager
__()
Definition: __.php:13
$storeCode
Definition: indexer.php:15
__construct(\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Module\Manager $moduleManager, \Magento\Config\Model\Config\Structure\Element\Iterator\Field $childrenIterator, \Magento\Config\Model\Config\BackendClone\Factory $cloneModelFactory, \Magento\Config\Model\Config\Structure\Element\Dependency\Mapper $dependencyMapper)
Definition: Group.php:35
$value
Definition: gender.phtml:16
populateFieldset(\Magento\Framework\Data\Form\Element\Fieldset $fieldset)
Definition: Group.php:79