本文整理汇总了PHP中Symfony\Component\HttpFoundation\Request::getCharsets方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getCharsets方法的具体用法?PHP Request::getCharsets怎么用?PHP Request::getCharsets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Request
的用法示例。
在下文中一共展示了Request::getCharsets方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createContexts
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;
}
示例2: logRequest
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: testGetCharsets
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());
}
示例4: mapRequest
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;
}