Example #1
0
 public function testTransform()
 {
     $config = array('tab_1' => array('sort_order' => array('#text' => 10), 'frontend_type' => array('#text' => 'text'), 'class' => array('#text' => 'css class'), 'label' => array('#text' => 'tab label'), 'comment' => array('#cdata-section' => 'tab comment')), 'tab_2' => array());
     $expected = array(array('nodeName' => 'tab', '@attributes' => array('id' => 'tab_1', 'sortOrder' => 10, 'type' => 'text', 'class' => 'css class'), 'parameters' => array(array('name' => 'label', '#text' => 'tab label'), array('name' => 'comment', '#cdata-section' => 'tab comment'))), array('nodeName' => 'tab', '@attributes' => array('id' => 'tab_2'), 'parameters' => array()));
     $actual = $this->_object->transform($config);
     $this->assertEquals($expected, $actual);
 }
Example #2
0
 public function testTransform()
 {
     $config = ['tab_1' => ['sort_order' => ['#text' => 10], 'frontend_type' => ['#text' => 'text'], 'class' => ['#text' => 'css class'], 'label' => ['#text' => 'tab label'], 'comment' => ['#cdata-section' => 'tab comment']], 'tab_2' => []];
     $expected = [['nodeName' => 'tab', '@attributes' => ['id' => 'tab_1', 'sortOrder' => 10, 'type' => 'text', 'class' => 'css class'], 'parameters' => [['name' => 'label', '#text' => 'tab label'], ['name' => 'comment', '#cdata-section' => 'tab comment']]], ['nodeName' => 'tab', '@attributes' => ['id' => 'tab_2'], 'parameters' => []]];
     $actual = $this->_object->transform($config);
     $this->assertEquals($expected, $actual);
 }
Example #3
0
 /**
  * Transform configuration
  *
  * @param array $config
  * @return array
  */
 public function transform(array $config)
 {
     $output = array();
     $output['comment'] = $config['comment'];
     $tabsConfig = isset($config['tabs']) ? $config['tabs'] : array();
     $sectionsConfig = isset($config['sections']) ? $config['sections'] : array();
     /** @var array $nodes  */
     $nodes = $this->_tabMapper->transform($tabsConfig);
     $transformedSections = $this->_sectionMapper->transform($sectionsConfig);
     $nodes = array_merge($nodes, $transformedSections);
     $output['nodes'] = $nodes;
     return $output;
 }