255 lines
12 KiB
YAML
255 lines
12 KiB
YAML
name: RequestDataCollector
|
|
class_comment: '# * @author Fabien Potencier <fabien@symfony.com>
|
|
|
|
# *
|
|
|
|
# * @final'
|
|
dependencies:
|
|
- name: EventSubscriberInterface
|
|
type: class
|
|
source: Symfony\Component\EventDispatcher\EventSubscriberInterface
|
|
- name: Cookie
|
|
type: class
|
|
source: Symfony\Component\HttpFoundation\Cookie
|
|
- name: ParameterBag
|
|
type: class
|
|
source: Symfony\Component\HttpFoundation\ParameterBag
|
|
- name: Request
|
|
type: class
|
|
source: Symfony\Component\HttpFoundation\Request
|
|
- name: RequestStack
|
|
type: class
|
|
source: Symfony\Component\HttpFoundation\RequestStack
|
|
- name: Response
|
|
type: class
|
|
source: Symfony\Component\HttpFoundation\Response
|
|
- name: SessionBagInterface
|
|
type: class
|
|
source: Symfony\Component\HttpFoundation\Session\SessionBagInterface
|
|
- name: SessionInterface
|
|
type: class
|
|
source: Symfony\Component\HttpFoundation\Session\SessionInterface
|
|
- name: ControllerEvent
|
|
type: class
|
|
source: Symfony\Component\HttpKernel\Event\ControllerEvent
|
|
- name: ResponseEvent
|
|
type: class
|
|
source: Symfony\Component\HttpKernel\Event\ResponseEvent
|
|
- name: KernelEvents
|
|
type: class
|
|
source: Symfony\Component\HttpKernel\KernelEvents
|
|
- name: Data
|
|
type: class
|
|
source: Symfony\Component\VarDumper\Cloner\Data
|
|
properties: []
|
|
methods:
|
|
- name: getContent
|
|
visibility: public
|
|
parameters: []
|
|
comment: "# * @author Fabien Potencier <fabien@symfony.com>\n# *\n# * @final\n#\
|
|
\ */\n# class RequestDataCollector extends DataCollector implements EventSubscriberInterface,\
|
|
\ LateDataCollectorInterface\n# {\n# /**\n# * @var \\SplObjectStorage<Request,\
|
|
\ callable>\n# */\n# private \\SplObjectStorage $controllers;\n# private array\
|
|
\ $sessionUsages = [];\n# \n# public function __construct(\n# private ?RequestStack\
|
|
\ $requestStack = null,\n# ) {\n# $this->controllers = new \\SplObjectStorage();\n\
|
|
# }\n# \n# public function collect(Request $request, Response $response, ?\\Throwable\
|
|
\ $exception = null): void\n# {\n# // attributes are serialized and as they can\
|
|
\ be anything, they need to be converted to strings.\n# $attributes = [];\n# $route\
|
|
\ = '';\n# foreach ($request->attributes->all() as $key => $value) {\n# if ('_route'\
|
|
\ === $key) {\n# $route = \\is_object($value) ? $value->getPath() : $value;\n\
|
|
# $attributes[$key] = $route;\n# } else {\n# $attributes[$key] = $value;\n# }\n\
|
|
# }\n# \n# $content = $request->getContent();\n# \n# $sessionMetadata = [];\n\
|
|
# $sessionAttributes = [];\n# $flashes = [];\n# if (!$request->attributes->getBoolean('_stateless')\
|
|
\ && $request->hasSession()) {\n# $session = $request->getSession();\n# if ($session->isStarted())\
|
|
\ {\n# $sessionMetadata['Created'] = date(\\DATE_RFC822, $session->getMetadataBag()->getCreated());\n\
|
|
# $sessionMetadata['Last used'] = date(\\DATE_RFC822, $session->getMetadataBag()->getLastUsed());\n\
|
|
# $sessionMetadata['Lifetime'] = $session->getMetadataBag()->getLifetime();\n\
|
|
# $sessionAttributes = $session->all();\n# $flashes = $session->getFlashBag()->peekAll();\n\
|
|
# }\n# }\n# \n# $statusCode = $response->getStatusCode();\n# \n# $responseCookies\
|
|
\ = [];\n# foreach ($response->headers->getCookies() as $cookie) {\n# $responseCookies[$cookie->getName()]\
|
|
\ = $cookie;\n# }\n# \n# $dotenvVars = [];\n# foreach (explode(',', $_SERVER['SYMFONY_DOTENV_VARS']\
|
|
\ ?? $_ENV['SYMFONY_DOTENV_VARS'] ?? '') as $name) {\n# if ('' !== $name && isset($_ENV[$name]))\
|
|
\ {\n# $dotenvVars[$name] = $_ENV[$name];\n# }\n# }\n# \n# $this->data = [\n#\
|
|
\ 'method' => $request->getMethod(),\n# 'format' => $request->getRequestFormat(),\n\
|
|
# 'content_type' => $response->headers->get('Content-Type', 'text/html'),\n# 'status_text'\
|
|
\ => Response::$statusTexts[$statusCode] ?? '',\n# 'status_code' => $statusCode,\n\
|
|
# 'request_query' => $request->query->all(),\n# 'request_request' => $request->request->all(),\n\
|
|
# 'request_files' => $request->files->all(),\n# 'request_headers' => $request->headers->all(),\n\
|
|
# 'request_server' => $request->server->all(),\n# 'request_cookies' => $request->cookies->all(),\n\
|
|
# 'request_attributes' => $attributes,\n# 'route' => $route,\n# 'response_headers'\
|
|
\ => $response->headers->all(),\n# 'response_cookies' => $responseCookies,\n#\
|
|
\ 'session_metadata' => $sessionMetadata,\n# 'session_attributes' => $sessionAttributes,\n\
|
|
# 'session_usages' => array_values($this->sessionUsages),\n# 'stateless_check'\
|
|
\ => $this->requestStack?->getMainRequest()?->attributes->get('_stateless') ??\
|
|
\ false,\n# 'flashes' => $flashes,\n# 'path_info' => $request->getPathInfo(),\n\
|
|
# 'controller' => 'n/a',\n# 'locale' => $request->getLocale(),\n# 'dotenv_vars'\
|
|
\ => $dotenvVars,\n# ];\n# \n# if (isset($this->data['request_headers']['php-auth-pw']))\
|
|
\ {\n# $this->data['request_headers']['php-auth-pw'] = '******';\n# }\n# \n# if\
|
|
\ (isset($this->data['request_server']['PHP_AUTH_PW'])) {\n# $this->data['request_server']['PHP_AUTH_PW']\
|
|
\ = '******';\n# }\n# \n# if (isset($this->data['request_request']['_password']))\
|
|
\ {\n# $encodedPassword = rawurlencode($this->data['request_request']['_password']);\n\
|
|
# $content = str_replace('_password='.$encodedPassword, '_password=******', $content);\n\
|
|
# $this->data['request_request']['_password'] = '******';\n# }\n# \n# $this->data['content']\
|
|
\ = $content;\n# \n# foreach ($this->data as $key => $value) {\n# if (!\\is_array($value))\
|
|
\ {\n# continue;\n# }\n# if ('request_headers' === $key || 'response_headers'\
|
|
\ === $key) {\n# $this->data[$key] = array_map(fn ($v) => isset($v[0]) && !isset($v[1])\
|
|
\ ? $v[0] : $v, $value);\n# }\n# }\n# \n# if (isset($this->controllers[$request]))\
|
|
\ {\n# $this->data['controller'] = $this->parseController($this->controllers[$request]);\n\
|
|
# unset($this->controllers[$request]);\n# }\n# \n# if ($request->attributes->has('_redirected')\
|
|
\ && $redirectCookie = $request->cookies->get('sf_redirect')) {\n# $this->data['redirect']\
|
|
\ = json_decode($redirectCookie, true);\n# \n# $response->headers->clearCookie('sf_redirect');\n\
|
|
# }\n# \n# if ($response->isRedirect()) {\n# $response->headers->setCookie(new\
|
|
\ Cookie(\n# 'sf_redirect',\n# json_encode([\n# 'token' => $response->headers->get('x-debug-token'),\n\
|
|
# 'route' => $request->attributes->get('_route', 'n/a'),\n# 'method' => $request->getMethod(),\n\
|
|
# 'controller' => $this->parseController($request->attributes->get('_controller')),\n\
|
|
# 'status_code' => $statusCode,\n# 'status_text' => Response::$statusTexts[$statusCode],\n\
|
|
# ]),\n# 0, '/', null, $request->isSecure(), true, false, 'lax'\n# ));\n# }\n\
|
|
# \n# $this->data['identifier'] = $this->data['route'] ?: (\\is_array($this->data['controller'])\
|
|
\ ? $this->data['controller']['class'].'::'.$this->data['controller']['method'].'()'\
|
|
\ : $this->data['controller']);\n# \n# if ($response->headers->has('x-previous-debug-token'))\
|
|
\ {\n# $this->data['forward_token'] = $response->headers->get('x-previous-debug-token');\n\
|
|
# }\n# }\n# \n# public function lateCollect(): void\n# {\n# $this->data = $this->cloneVar($this->data);\n\
|
|
# }\n# \n# public function reset(): void\n# {\n# parent::reset();\n# $this->controllers\
|
|
\ = new \\SplObjectStorage();\n# $this->sessionUsages = [];\n# }\n# \n# public\
|
|
\ function getMethod(): string\n# {\n# return $this->data['method'];\n# }\n# \n\
|
|
# public function getPathInfo(): string\n# {\n# return $this->data['path_info'];\n\
|
|
# }\n# \n# public function getRequestRequest(): ParameterBag\n# {\n# return new\
|
|
\ ParameterBag($this->data['request_request']->getValue());\n# }\n# \n# public\
|
|
\ function getRequestQuery(): ParameterBag\n# {\n# return new ParameterBag($this->data['request_query']->getValue());\n\
|
|
# }\n# \n# public function getRequestFiles(): ParameterBag\n# {\n# return new\
|
|
\ ParameterBag($this->data['request_files']->getValue());\n# }\n# \n# public function\
|
|
\ getRequestHeaders(): ParameterBag\n# {\n# return new ParameterBag($this->data['request_headers']->getValue());\n\
|
|
# }\n# \n# public function getRequestServer(bool $raw = false): ParameterBag\n\
|
|
# {\n# return new ParameterBag($this->data['request_server']->getValue($raw));\n\
|
|
# }\n# \n# public function getRequestCookies(bool $raw = false): ParameterBag\n\
|
|
# {\n# return new ParameterBag($this->data['request_cookies']->getValue($raw));\n\
|
|
# }\n# \n# public function getRequestAttributes(): ParameterBag\n# {\n# return\
|
|
\ new ParameterBag($this->data['request_attributes']->getValue());\n# }\n# \n\
|
|
# public function getResponseHeaders(): ParameterBag\n# {\n# return new ParameterBag($this->data['response_headers']->getValue());\n\
|
|
# }\n# \n# public function getResponseCookies(): ParameterBag\n# {\n# return new\
|
|
\ ParameterBag($this->data['response_cookies']->getValue());\n# }\n# \n# public\
|
|
\ function getSessionMetadata(): array\n# {\n# return $this->data['session_metadata']->getValue();\n\
|
|
# }\n# \n# public function getSessionAttributes(): array\n# {\n# return $this->data['session_attributes']->getValue();\n\
|
|
# }\n# \n# public function getStatelessCheck(): bool\n# {\n# return $this->data['stateless_check'];\n\
|
|
# }\n# \n# public function getSessionUsages(): Data|array\n# {\n# return $this->data['session_usages'];\n\
|
|
# }\n# \n# public function getFlashes(): array\n# {\n# return $this->data['flashes']->getValue();\n\
|
|
# }\n# \n# /**\n# * @return string|resource"
|
|
- name: isJsonRequest
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getPrettyJson
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getContentType
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getStatusText
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getStatusCode
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getFormat
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getLocale
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getDotenvVars
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getRoute
|
|
visibility: public
|
|
parameters: []
|
|
comment: '# * Gets the route name.
|
|
|
|
# *
|
|
|
|
# * The _route request attributes is automatically set by the Router Matcher.'
|
|
- name: getIdentifier
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getRouteParams
|
|
visibility: public
|
|
parameters: []
|
|
comment: '# * Gets the route parameters.
|
|
|
|
# *
|
|
|
|
# * The _route_params request attributes is automatically set by the RouterListener.'
|
|
- name: getController
|
|
visibility: public
|
|
parameters: []
|
|
comment: '# * Gets the parsed controller.
|
|
|
|
# *
|
|
|
|
# * @return array|string|Data The controller as a string or array of data
|
|
|
|
# * with keys ''class'', ''method'', ''file'' and ''line'''
|
|
- name: getRedirect
|
|
visibility: public
|
|
parameters: []
|
|
comment: '# * Gets the previous request attributes.
|
|
|
|
# *
|
|
|
|
# * @return array|Data|false A legacy array of data from the previous redirection
|
|
response
|
|
|
|
# * or false otherwise'
|
|
- name: getForwardToken
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: onKernelController
|
|
visibility: public
|
|
parameters:
|
|
- name: event
|
|
comment: null
|
|
- name: onKernelResponse
|
|
visibility: public
|
|
parameters:
|
|
- name: event
|
|
comment: null
|
|
- name: getSubscribedEvents
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: getName
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: collectSessionUsage
|
|
visibility: public
|
|
parameters: []
|
|
comment: null
|
|
- name: parseController
|
|
visibility: private
|
|
parameters:
|
|
- name: controller
|
|
comment: '# * @return array|string An array of controller data or a simple string'
|
|
traits:
|
|
- Symfony\Component\EventDispatcher\EventSubscriberInterface
|
|
- Symfony\Component\HttpFoundation\Cookie
|
|
- Symfony\Component\HttpFoundation\ParameterBag
|
|
- Symfony\Component\HttpFoundation\Request
|
|
- Symfony\Component\HttpFoundation\RequestStack
|
|
- Symfony\Component\HttpFoundation\Response
|
|
- Symfony\Component\HttpFoundation\Session\SessionBagInterface
|
|
- Symfony\Component\HttpFoundation\Session\SessionInterface
|
|
- Symfony\Component\HttpKernel\Event\ControllerEvent
|
|
- Symfony\Component\HttpKernel\Event\ResponseEvent
|
|
- Symfony\Component\HttpKernel\KernelEvents
|
|
- Symfony\Component\VarDumper\Cloner\Data
|
|
interfaces:
|
|
- EventSubscriberInterface
|