getCharsets() public method

Gets a list of charsets acceptable by the client browser.
public getCharsets ( ) : array
return array List of charsets in preferable order
 public function createContexts(Request $request)
 {
     $map = array('request_method' => $request->getMethod(), 'request_uri' => $request->getRequestUri(), 'request_route' => $request->attributes->get('_route'), 'request_host' => $request->getHost(), 'request_port' => $request->getPort(), 'request_scheme' => $request->getScheme(), 'request_client_ip' => $request->getClientIp(), 'request_content_type' => $request->getContentType(), 'request_acceptable_content_types' => $request->getAcceptableContentTypes(), 'request_etags' => $request->getETags(), 'request_charsets' => $request->getCharsets(), 'request_languages' => $request->getLanguages(), 'request_locale' => $request->getLocale(), 'request_auth_user' => $request->getUser(), 'request_auth_has_password' => !is_null($request->getPassword()));
     // Attributes from newer versions.
     if (method_exists($request, 'getEncodings')) {
         $map['request_encodings'] = $request->getEncodings();
     }
     if (method_exists($request, 'getClientIps')) {
         $map['request_client_ips'] = $request->getClientIps();
     }
     return $map;
 }
 protected function logRequest(Request $request)
 {
     $msg = 'Request "{request_method} {request_uri}"';
     $map = array('request_method' => $request->getMethod(), 'request_uri' => $request->getRequestUri(), 'request_host' => $request->getHost(), 'request_port' => $request->getPort(), 'request_scheme' => $request->getScheme(), 'request_client_ip' => $request->getClientIp(), 'request_content_type' => $request->getContentType(), 'request_acceptable_content_types' => $request->getAcceptableContentTypes(), 'request_etags' => $request->getETags(), 'request_charsets' => $request->getCharsets(), 'request_languages' => $request->getLanguages(), 'request_locale' => $request->getLocale(), 'request_auth_user' => $request->getUser(), 'request_auth_has_password' => !is_null($request->getPassword()));
     // Attributes from newer versions.
     if (method_exists($request, 'getEncodings')) {
         $map['request_encodings'] = $request->getEncodings();
     }
     if (method_exists($request, 'getClientIps')) {
         $map['request_client_ips'] = $request->getClientIps();
     }
     $this->logger->log($this->logLevel, $msg, $map);
 }
示例#3
0
 public function testGetCharsets()
 {
     $request = new Request();
     $this->assertEquals(array(), $request->getCharsets());
     $request->headers->set('Accept-Charset', 'ISO-8859-1, US-ASCII, UTF-8; q=0.8, ISO-10646-UCS-2; q=0.6');
     $this->assertEquals(array(), $request->getCharsets());
     // testing caching
     $request = new Request();
     $request->headers->set('Accept-Charset', 'ISO-8859-1, US-ASCII, UTF-8; q=0.8, ISO-10646-UCS-2; q=0.6');
     $this->assertEquals(array('ISO-8859-1', 'US-ASCII', 'UTF-8', 'ISO-10646-UCS-2'), $request->getCharsets());
     $request = new Request();
     $request->headers->set('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7');
     $this->assertEquals(array('ISO-8859-1', 'utf-8', '*'), $request->getCharsets());
 }
 private function mapRequest(Request $request, $full = false)
 {
     $mapRequest = array();
     if ($full) {
         $mapRequest['ip'] = $request->getClientIp();
         $mapRequest['method'] = $request->getMethod();
         $mapRequest['host'] = $request->getHttpHost();
         $mapRequest['port'] = $request->getPort();
         $mapRequest['scheme'] = $request->getScheme();
         $mapRequest['uri'] = $request->getUri();
         $mapRequest['requestUri'] = $request->getRequestUri();
         $mapRequest['queryString'] = $request->getQueryString();
         $mapRequest['isSecure'] = $request->isSecure();
         $mapRequest['content'] = $request->getContent();
         $mapRequest['preferredLanguage'] = $request->getPreferredLanguage();
         $mapRequest['languages'] = $request->getLanguages();
         $mapRequest['charsets'] = $request->getCharsets();
         $mapRequest['acceptableContentTypes'] = $request->getAcceptableContentTypes();
         $mapRequest['isXmlHttpRequest'] = $request->isXmlHttpRequest();
         $mapRequest['to_string'] = $request->__toString();
         $mapRequest['server'] = $request->server;
         $mapRequest['headers'] = $request->headers;
         $mapRequest['cookies'] = $request->cookies;
         $mapRequest['oriLocale'] = $request->getLocale();
         $mapRequest['guessedLocale'] = $this->getLocaleManager()->getGuessedLocale();
     }
     $mapRequest['locale'] = $request->getLocale();
     $mapRequest['_route'] = $request->get('_route');
     $mapRequest['_controller'] = $request->get('_controller');
     $mapRequest['_route_params'] = $request->get('_route_params');
     return $mapRequest;
 }