Exemplo n.º 1
0
 public function addSetting(DmSetting $setting)
 {
     $settingName = $setting->get('name');
     $this->widgetSchema[$settingName] = $this->getSettingWidget($setting);
     //    $this->widgetSchema[$settingName]->setDefault($setting->get('value'));
     $this->widgetSchema->setHelp($settingName, $setting->get('description'));
     $this->validatorSchema[$settingName] = $this->getSettingValidator($setting)->setOption('required', false);
 }
Exemplo n.º 2
0
 /**
  * Sets a config parameter.
  *
  * If a config parameter with the name already exists the value will be overridden.
  * If config parameter does not exist, one will be created, name & value will be 
  * 	assigned and value will be returned
  *
  * @param string $name  A config parameter name
  * @param mixed  $value A config parameter value
  */
 public static function set($name, $value)
 {
     /*
      * Convert booleans to 0, 1 not to fail doctrine validation
      */
     if (is_bool($value)) {
         $value = (string) (int) $value;
     }
     $setting = dmDb::query('DmSetting s')->where('s.name = ?', $name)->withI18n(self::$culture)->fetchOne();
     if (!$setting) {
         $setting = new DmSetting();
         $setting->set('name', $name);
     }
     $setting->set('value', $value);
     $setting->save();
     self::$config[$name] = $value;
     self::$dispatcher->notify(new sfEvent(null, 'dm.config.updated', array('setting' => $setting, 'culture' => self::$culture)));
     // reassign setting value as it may have changed
     return self::$config[$name] = $setting->get('value');
 }
Exemplo n.º 3
0
 protected function getSelectSettingWidget(DmSetting $setting)
 {
     $widget = new sfWidgetFormSelect(array('choices' => $setting->getParamsArray()));
     return $widget->setDefault($setting->get('value'));
 }