Пример #1
0
 /**
  * Builds group node, called recursively
  *
  * @param array $nodes
  * @param int   $correctFieldsLevel fields should be placed on the same levels that comes from view
  * @param int   $level              current level
  *
  * @throws ItemNotFoundException
  * @throws \Exception
  * @return array
  */
 protected function buildGroupNode($nodes, $correctFieldsLevel, $level = 0)
 {
     $level++;
     foreach ($nodes as $name => $node) {
         if (is_array($node) && isset($node['children'])) {
             $group = $this->configBag->getGroupsNode($name);
             if ($group === false) {
                 throw new ItemNotFoundException(sprintf('Group "%s" is not defined.', $name));
             }
             $data = $this->buildGroupNode($node['children'], $correctFieldsLevel, $level);
             $node = new GroupNodeDefinition($name, array_merge($group, $nodes[$name]), $data);
             $node->setLevel($level);
             $nodes[$node->getName()] = $node;
         } else {
             if ($level !== $correctFieldsLevel) {
                 throw new \Exception(sprintf('Field "%s" will not be ever rendered. Please check nesting level', $node));
             }
             $nodes[$name] = $this->buildFieldNode($node);
         }
     }
     return $nodes;
 }
Пример #2
0
 /**
  * @dataProvider groupsNodeDataProvider
  *
  * @param array  $config
  * @param string $name
  * @param mixed  $expectedResult
  */
 public function testGetGroupsNode($config, $name, $expectedResult)
 {
     $configBag = new ConfigBag($config, $this->container);
     $this->assertEquals($expectedResult, $configBag->getGroupsNode($name));
 }