private function getBestFormat($app) { $negotiator = new \Negotiation\FormatNegotiator(); $acceptHeader = $app->request->headers->get('accept'); $priorities = array('application/json', 'application/xml', 'text/plain', '*/*'); return $negotiator->getBestFormat($acceptHeader, $priorities); }
protected function negotiateType() { $this->content_return_type = 'html'; //Default if ($this->getHeader('ACCEPT', false)) { $negotiator = new \Negotiation\FormatNegotiator(); $acceptable_types = array('html', '*/*'); $acceptable_types = array('html', 'json', 'xml', '*/*'); $this->content_return_type = $negotiator->getBestFormat($this->getHeader('ACCEPT'), $acceptable_types); if ($this->content_return_type == '*/*') { $this->content_return_type = 'html'; } } }