public function __construct(Gadget $gadget, $options = array(), $CSRFSecret = null) { $this->gadget = $gadget; parent::__construct(array(), $options, $CSRFSecret); $config = Doctrine::getTable('Gadget')->getGadgetConfigListByType($options['type']); if (empty($config[$gadget->getName()]['config'])) { throw new RuntimeException('The gadget has not registered or it doesn\'t have any configuration items.'); } $gadgetConfig = $config[$gadget->getName()]['config']; foreach ($gadgetConfig as $key => $value) { $this->setWidget($key, opFormItemGenerator::generateWidget($value)); $this->setValidator($key, opFormItemGenerator::generateValidator($value)); $config = Doctrine::getTable('GadgetConfig')->retrieveByGadgetIdAndName($gadget->getId(), $key); if ($config) { $this->setDefault($key, $config->getValue()); } } $this->widgetSchema->setNameFormat('gadget_config[%s]'); }
/** * Tests Gadget->getId() */ public function testGetId() { $this->Gadget->id = 'id'; $this->assertEquals('id', $this->Gadget->getId()); }