public function createConfig(array $config = [])
 {
     $options = [];
     for ($i = 1; $i <= 2; $i++) {
         $options[] = ['type' => 'bool', 'key' => "option_{$i}", 'label' => "option {$i}", 'value' => $i & 1];
     }
     $config = array_merge_recursive(['options' => $options], $config);
     $factory = new ConfigFactory();
     return $factory->createConfig('choice', $config);
 }
 public function build($type, array $options = [], ConfigFactory $factory)
 {
     $options = $this->buildOptions($options);
     $config = new ChoiceConfig();
     $config->setKey($options['key']);
     $config->setLabel($options['label']);
     $config->setLimit($options['limit']);
     foreach ($options['options'] as $option) {
         $config->addOption($factory->createConfig($option['type'], $option));
     }
     return $config;
 }
Example #3
0
 private function factoryConfig($type, $value)
 {
     $factory = new ConfigFactory();
     return $factory->createConfig($type, ['key' => self::TEST_KEY, 'label' => self::TEST_LABEL, 'value' => $value]);
 }
 public function createConfig($type, array $options)
 {
     $factory = new ConfigFactory();
     return $factory->createConfig($type, $options);
 }