示例#1
0
 /**
  * Work through all Set commands.
  *
  * @return void
  */
 public function enumerateSets()
 {
     foreach ($this->sets as $set) {
         $value = $set->getValue();
         $key = $set->getProperty();
         $section = $set->getSection();
         $operation = $set->getOperation();
         if ($value !== null) {
             try {
                 $this->ini->set($section, $key, $value);
                 $this->log("[{$section}] {$key} set to {$value}", Project::MSG_DEBUG);
             } catch (Exception $ex) {
                 $this->log("Error setting value for section '" . $section . "', key '" . $key . "'");
                 $this->log($ex->getMessage(), Project::MSG_DEBUG);
             }
         } elseif ($operation !== null) {
             $v = $this->ini->get($section, $key);
             // value might be wrapped in quotes with a semicolon at the end
             if (!is_numeric($v)) {
                 if (preg_match('/^"(\\d*)";?$/', $v, $match)) {
                     $v = $match[1];
                 } elseif (preg_match("/^'(\\d*)';?\$/", $v, $match)) {
                     $v = $match[1];
                 } else {
                     $this->log("Value {$v} is not numeric. Skipping {$operation} operation.");
                     continue;
                 }
             }
             if ($operation == '+') {
                 ++$v;
             } elseif ($operation == '-') {
                 --$v;
             } else {
                 if ($operation != '-' && $operation != '+') {
                     $msg = "Unrecognised operation {$operation}";
                     if ($this->haltonerror) {
                         throw new BuildException($msg);
                     }
                     $this->log($msg, Project::MSG_ERR);
                 }
             }
             try {
                 $this->ini->set($section, $key, $v);
                 $this->log("[{$section}] {$key} set to {$v}", Project::MSG_DEBUG);
             } catch (Exception $ex) {
                 $this->log("Error setting value for section '" . $section . "', key '" . $key . "'");
                 $this->log($ex->getMessage(), Project::MSG_DEBUG);
             }
         } else {
             $this->log("Set: value and operation are both not set", Project::MSG_ERR);
         }
     }
 }