Esempio n. 1
0
 /**
  * @param string $code
  * @param array  $config
  *
  * @return BlockConfig
  */
 protected function addBlock($code, $config = [])
 {
     if ($this->formConfig->hasBlock($code)) {
         $block = $this->formConfig->getBlock($code);
     } else {
         $block = new BlockConfig($code);
     }
     if (!empty($config['title'])) {
         $block->setTitle($config['title']);
     } else {
         $title = $block->getTitle();
         if (empty($title)) {
             $block->setTitle(ucfirst($code));
         }
     }
     if ($this->hasValue($config, 'description')) {
         $block->setDescription($config['description']);
     }
     if ($this->hasValue($config, 'class')) {
         $block->setClass($config['class']);
     }
     if ($this->hasValue($config, 'priority')) {
         $block->setPriority($config['priority']);
     }
     if (!empty($config['subblocks'])) {
         foreach ($config['subblocks'] as $subBlockCode => $subBlockConfig) {
             $this->addSubBlock($block, $subBlockCode, (array) $subBlockConfig);
         }
     }
     $this->formConfig->addBlock($block);
     return $block;
 }
Esempio n. 2
0
 /**
  * @param        $code
  * @param  array $blockConfig
  * @return BlockConfig
  */
 protected function createBlock($code, $blockConfig = [])
 {
     if ($this->formConfig->hasBlock($code)) {
         $block = $this->formConfig->getBlock($code);
     } else {
         $block = new BlockConfig($code);
     }
     $block->setClass($this->accessor->getValue($blockConfig, '[class]'));
     $block->setPriority($this->accessor->getValue($blockConfig, '[priority]'));
     $title = $this->accessor->getValue($blockConfig, '[title]') ? $this->accessor->getValue($blockConfig, '[title]') : ucfirst($code);
     $block->setTitle($title);
     $block->setDescription($this->accessor->getValue($blockConfig, '[description]'));
     foreach ((array) $this->accessor->getValue($blockConfig, '[subblocks]') as $subCode => $subBlockConfig) {
         $block->addSubBlock($this->createSubBlock($subCode, (array) $subBlockConfig));
     }
     $this->formConfig->addBlock($block);
     return $block;
 }
Esempio n. 3
0
 public function testException()
 {
     /** test getSubBlock Exception */
     $this->setExpectedException('\\PHPUnit_Framework_Error_Notice', 'Undefined index: testBlock');
     $this->formConfig->getBlock('testBlock');
 }