本文整理汇总了PHP中Symfony\Component\HttpFoundation\Request::getRealMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getRealMethod方法的具体用法?PHP Request::getRealMethod怎么用?PHP Request::getRealMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Request
的用法示例。
在下文中一共展示了Request::getRealMethod方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRequestParameters
public function getRequestParameters()
{
if ($this->request->getRealMethod() === 'POST') {
return $this->request->request->all();
} else {
return $this->request->query->all();
}
}
示例2: logRequest
/**
* Log an incoming request from the middleware.
*
* @param Request $request
* The incoming request.
* @param int $type
* The type of request (master or sub request).
*/
protected function logRequest(Request $request, $type = HttpKernelInterface::MASTER_REQUEST)
{
if ($type == HttpKernelInterface::MASTER_REQUEST) {
// Starts timers and logs.
Database::startLog('console_logger');
if ($request->getRealMethod() == 'POST') {
$parameters = $request->request->all();
$parameters = $this->sanitizeParameters($parameters);
if (!empty($parameters)) {
$this->logger->log($this->logLevel, 'Request parameters', $parameters);
}
}
}
}
示例3: handleRequestToken
/**
* Handles the request token.
*
* @throws AjaxRedirectResponseException|InvalidRequestTokenException If the token is invalid
*/
private function handleRequestToken()
{
// Deprecated since Contao 4.0, to be removed in Contao 5.0
if (!defined('REQUEST_TOKEN')) {
define('REQUEST_TOKEN', $this->tokenManager->getToken($this->csrfTokenName)->getValue());
}
if (null === $this->request || 'POST' !== $this->request->getRealMethod()) {
return;
}
$token = new CsrfToken($this->csrfTokenName, $this->request->request->get('REQUEST_TOKEN'));
if ($this->tokenManager->isTokenValid($token)) {
return;
}
if ($this->request->isXmlHttpRequest()) {
throw new AjaxRedirectResponseException($this->router->generate('contao_backend'));
}
throw new InvalidRequestTokenException('Invalid request token. Please reload the page and try again.');
}
示例4: logRequest
/**
* Request のログを出力する.
*
* @param Request $request
* @return string Request のログ
*/
protected function logRequest(Request $request)
{
$log = '';
$log .= $this->logKeyValuePair('REMOTE_ADDR', $request->getClientIp());
$log .= $this->logKeyValuePair('SCRIPT_NAME', $request->getScriptName());
$log .= $this->logKeyValuePair('PATH_INFO', $request->getPathInfo());
$log .= $this->logKeyValuePair('BASE_PATH', $request->getBasePath());
$log .= $this->logKeyValuePair('BASE_URL', $request->getBaseUrl());
$log .= $this->logKeyValuePair('SCHEME', $request->getScheme());
$log .= $this->logKeyValuePair('REMOTE_USER', $request->getUser());
$log .= $this->logKeyValuePair('HTTP_HOST', $request->getSchemeAndHttpHost());
$log .= $this->logKeyValuePair('REQUEST_URI', $request->getRequestUri());
$log .= $this->logKeyValuePair('METHOD', $request->getRealMethod());
$log .= $this->logKeyValuePair('LOCALE', $request->getLocale());
// $log .= $this->logArray($request->server->all(), '[server]'); // 大量にログ出力される...
$log .= $this->logArray($request->headers->all(), '[header]');
$log .= $this->logArray($request->query->all(), '[get]');
$log .= $this->logArray($request->request->all(), '[post]');
$log .= $this->logArray($request->attributes->all(), '[attributes]');
$log .= $this->logArray($request->cookies->all(), '[cookie]');
$log .= $this->logArray($request->files->all(), '[files]');
return $log;
}
示例5: indexAction
/**
* @param Request $request
* @return JsonResponse
*
* @Route("/{entity}/{id}", name="basic_auth", defaults={"id" = 1})
*/
public function indexAction(Request $request)
{
/** @var User $user */
$user = $this->getUser();
return new JsonResponse(['method' => $request->getRealMethod(), 'path' => $request->getPathInfo(), 'query_params' => $request->query->all(), 'headers' => $request->headers->all(), 'content' => $this->getContent($request), 'files' => $_FILES, 'user' => ['username' => $user->getUsername(), 'password' => $user->getPassword()]]);
}
示例6: canSkipTokenCheck
/**
* Checks if the token check can be skipped.
*
* @return bool True if the token check can be skipped
*/
private function canSkipTokenCheck()
{
return null === $this->request || 'POST' !== $this->request->getRealMethod() || !$this->request->attributes->has('_token_check') || false === $this->request->attributes->get('_token_check');
}
示例7: __construct
/**
* Creates a Visitor object.
*
* @param \Symfony\Component\HttpFoundation\Request $request The request of the visitor
*/
public function __construct(Request $request)
{
$this->ip = $request->getClientIp();
$this->headers = $request->headers;
$this->method = $request->getRealMethod();
$this->uri = $request->getRequestUri();
$this->data = $request->request;
$this->scheme = $request->getScheme();
$this->protocol = $request->server->get('SERVER_PROTOCOL');
$userAgent = $request->headers->get('user-agent');
$this->userAgent = new UserAgent($userAgent);
$knownBrowsers = ['msie', 'firefox', 'chrome', 'safari', 'opera', 'konqueror', 'edge', 'lynx'];
$this->isBrowser = in_array($this->userAgent->getBrowserName(), $knownBrowsers);
}
示例8: format
/**
* @param Request $request
* @param Response $response
* @return string
*/
public function format(Request $request, Response $response)
{
return sprintf("%s %s %s %s <<<< %s %s %s %s", $request->getRealMethod(), $request->getRequestUri(), $this->formatHeaders($request->headers), $this->getContent($request), $response->getStatusCode(), Response::$statusTexts[$response->getStatusCode()], $this->formatHeaders($response->headers), $response->getContent());
}