Ejemplo n.º 1
0
 /**
  * Configures wrapped formatter class with any attributes on this element.
  */
 public function prepare()
 {
     if (!$this->formatter) {
         throw new BuildException("No formatter specified (use type or classname attribute)", $this->getLocation());
     }
     $out = $this->getOutputWriter();
     print "Setting output writer to: " . get_class($out) . "\n";
     $this->formatter->setOutput($out);
     if ($this->formatter instanceof PlainPDOResultFormatter) {
         // set any options that apply to the plain formatter
         $this->formatter->setShowheaders($this->showheaders);
         $this->formatter->setRowdelim($this->rowdelimiter);
         $this->formatter->setColdelim($this->coldelimiter);
     } elseif ($this->formatter instanceof XMLPDOResultFormatter) {
         // set any options that apply to the xml formatter
         $this->formatter->setEncoding($this->encoding);
         $this->formatter->setFormatOutput($this->formatoutput);
     }
     foreach ($this->formatterParams as $param) {
         $param = new Parameter();
         $method = 'set' . $param->getName();
         if (!method_exists($this->formatter, $param->getName())) {
             throw new BuildException("Formatter " . get_class($this->formatter) . " does not have a {$method} method.", $this->getLocation());
         }
         call_user_func(array($this->formatter, $method), $param->getValue());
     }
 }
 /**
  * Gets a configured output writer.
  *
  * @return Writer
  */
 private function getOutputWriter()
 {
     if ($this->useFile) {
         $of = $this->getOutfile();
         if (!$of) {
             $of = new PhingFile($this->formatter->getPreferredOutfile());
         }
         return new FileWriter($of, $this->append);
     } else {
         return $this->getDefaultOutput();
     }
 }
Ejemplo n.º 3
0
 /**
  * Write XML to file and free the DOM objects.
  */
 public function close()
 {
     $this->out->write($this->doc->saveXML());
     $this->rootNode = null;
     $this->doc = null;
     parent::close();
 }