Exemplo n.º 1
0
 public function testGetDependenciesWithDependencies()
 {
     $fields = ['field_4' => ['id' => 'section_2/group_3/field_4', 'value' => 'someValue', 'dependPath' => ['section_2', 'group_3', 'field_4']], 'field_1' => ['id' => 'section_1/group_3/field_1', 'value' => 'someValue', 'dependPath' => ['section_1', 'group_3', 'field_1']]];
     $this->_model->setData(['depends' => ['fields' => $fields]], 0);
     $this->_depMapperMock->expects($this->once())->method('getDependencies')->with($fields, 'test_scope', 'test_prefix')->will($this->returnArgument(0));
     $this->assertEquals($fields, $this->_model->getDependencies('test_prefix', 'test_scope'));
 }
Exemplo n.º 2
0
 /**
  * Initialize form element
  *
  * @param \Magento\Config\Model\Config\Structure\Element\Field $field
  * @param \Magento\Framework\Data\Form\Element\Fieldset $fieldset
  * @param string $path
  * @param string $fieldPrefix
  * @param string $labelPrefix
  * @return void
  */
 protected function _initElement(\Magento\Config\Model\Config\Structure\Element\Field $field, \Magento\Framework\Data\Form\Element\Fieldset $fieldset, $path, $fieldPrefix = '', $labelPrefix = '')
 {
     $inherit = true;
     $data = null;
     if (array_key_exists($path, $this->_configData)) {
         $data = $this->_configData[$path];
         $inherit = false;
     } elseif ($field->getConfigPath() !== null) {
         $data = $this->getConfigValue($field->getConfigPath());
     } else {
         $data = $this->getConfigValue($path);
     }
     $fieldRendererClass = $field->getFrontendModel();
     if ($fieldRendererClass) {
         $fieldRenderer = $this->_layout->getBlockSingleton($fieldRendererClass);
     } else {
         $fieldRenderer = $this->_fieldRenderer;
     }
     $fieldRenderer->setForm($this);
     $fieldRenderer->setConfigData($this->_configData);
     $elementName = $this->_generateElementName($field->getPath(), $fieldPrefix);
     $elementId = $this->_generateElementId($field->getPath($fieldPrefix));
     if ($field->hasBackendModel()) {
         $backendModel = $field->getBackendModel();
         $backendModel->setPath($path)->setValue($data)->setWebsite($this->getWebsiteCode())->setStore($this->getStoreCode())->afterLoad();
         $data = $backendModel->getValue();
     }
     $dependencies = $field->getDependencies($fieldPrefix, $this->getStoreCode());
     $this->_populateDependenciesBlock($dependencies, $elementId, $elementName);
     $sharedClass = $this->_getSharedCssClass($field);
     $requiresClass = $this->_getRequiresCssClass($field, $fieldPrefix);
     $formField = $fieldset->addField($elementId, $field->getType(), ['name' => $elementName, 'label' => $field->getLabel($labelPrefix), 'comment' => $field->getComment($data), 'tooltip' => $field->getTooltip(), 'hint' => $field->getHint(), 'value' => $data, 'inherit' => $inherit, 'class' => $field->getFrontendClass() . $sharedClass . $requiresClass, 'field_config' => $field->getData(), 'scope' => $this->getScope(), 'scope_id' => $this->getScopeId(), 'scope_label' => $this->getScopeLabel($field), 'can_use_default_value' => $this->canUseDefaultValue($field->showInDefault()), 'can_use_website_value' => $this->canUseWebsiteValue($field->showInWebsite())]);
     $field->populateInput($formField);
     if ($field->hasValidation()) {
         $formField->addClass($field->getValidation());
     }
     if ($field->getType() == 'multiselect') {
         $formField->setCanBeEmpty($field->canBeEmpty());
     }
     if ($field->hasOptions()) {
         $formField->setValues($field->getOptions());
     }
     $formField->setRenderer($fieldRenderer);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function getDependencies($fieldPrefix, $storeCode)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getDependencies');
     if (!$pluginInfo) {
         return parent::getDependencies($fieldPrefix, $storeCode);
     } else {
         return $this->___callPlugins('getDependencies', func_get_args(), $pluginInfo);
     }
 }