Пример #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());
     }
 }