Beispiel #1
0
 /**
  * @return \PSX\Data\WriterFactory
  */
 public function getWriterFactory()
 {
     $writer = new WriterFactory();
     $writer->addWriter(new Writer\Json(), 48);
     $writer->addWriter(new Writer\Html($this->get('template'), $this->get('reverse_router')), 40);
     $writer->addWriter(new Writer\Atom(), 32);
     $writer->addWriter(new Writer\Form(), 24);
     $writer->addWriter(new Writer\Jsonp(), 16);
     $writer->addWriter(new Writer\Jsonx(), 15);
     $writer->addWriter(new Writer\Soap($this->get('config')->get('psx_soap_namespace')), 8);
     $writer->addWriter(new Writer\Xml(), 0);
     return $writer;
 }
Beispiel #2
0
 /**
  * Returns the writer wich gets used if no writer was explicit selected
  *
  * @return \PSX\Data\WriterInterface
  */
 private function getPreferredWriter()
 {
     $parameters = $this->request->getUri()->getParameters();
     $format = isset($parameters['format']) ? $parameters['format'] : null;
     if (!empty($format)) {
         return $this->writerFactory->getWriterByFormat($format, $this->getSupportedWriter());
     } else {
         return $this->writerFactory->getWriterByContentType($this->request->getHeader('Accept'), $this->getSupportedWriter());
     }
 }