/** * @param BlockConfig $block * @param string $code * @param array $config * * @return SubBlockConfig */ protected function addSubBlock(BlockConfig $block, $code, $config = []) { if ($block->hasSubBlock($code)) { $subBlock = $block->getSubBlock($code); } else { $subBlock = new SubBlockConfig($code); } if ($this->hasValue($config, 'title')) { $subBlock->setTitle($config['title']); } if ($this->hasValue($config, 'description')) { $subBlock->setDescription($config['description']); } if ($this->hasValue($config, 'priority')) { $subBlock->setPriority($config['priority']); } if ($this->hasValue($config, 'useSpan')) { $subBlock->setUseSpan($config['useSpan']); } $block->addSubBlock($subBlock); return $subBlock; }
protected function getSubBlock($name, FormView $child, BlockConfig $block) { $subBlock = null; if (isset($child->vars['subblock']) && $block->hasSubBlock($child->vars['subblock'])) { $subBlock = $block->getSubBlock($child->vars['subblock']); } elseif (!isset($child->vars['subblock'])) { $subBlocks = $block->getSubBlocks(); $subBlock = reset($subBlocks); } if (!$subBlock) { if (isset($child->vars['subblock'])) { $subBlockCode = $child->vars['subblock']; } else { $subBlockCode = $name . '__subblock'; } $subBlock = $this->createSubBlock($subBlockCode, ['title' => null]); $block->addSubBlock($subBlock); } return $subBlock; }
public function testException() { /** test getSubBlock Exception */ $this->setExpectedException('\\PHPUnit_Framework_Error_Notice', 'Undefined index: testSubBlock'); $this->blockConfig->getSubBlock('testSubBlock'); }