Documentation

WebProcessor extends WebProcessor
in package
implements EventSubscriberInterface

WebProcessor override to read from the HttpFoundation's Request.

Tags
author

Jordi Boggiano j.boggiano@seld.be

final

Interfaces, Classes and Traits

EventSubscriberInterface
An EventSubscriber knows itself what events it is interested in.

Table of Contents

$extraFields  : array<string, string>
Default fields
$serverData  : array<string, mixed>|ArrayAccess<string, mixed>
__construct()  : mixed
__invoke()  : array<string|int, mixed>
addExtraField()  : self
getSubscribedEvents()  : array<string, string|array{0: string, 1: int}|list>
Returns an array of event names this subscriber wants to listen to.
onKernelRequest()  : mixed
appendExtraFields()  : array<string|int, mixed>

Properties

$extraFields

Default fields

protected array<string, string> $extraFields = ['url' => 'REQUEST_URI', 'ip' => 'REMOTE_ADDR', 'http_method' => 'REQUEST_METHOD', 'server' => 'SERVER_NAME', 'referrer' => 'HTTP_REFERER', 'user_agent' => 'HTTP_USER_AGENT']

Array is structured as [key in record.extra => key in $serverData]

$serverData

protected array<string, mixed>|ArrayAccess<string, mixed> $serverData

Methods

__construct()

public __construct([array<string|int, mixed>|null $extraFields = null ]) : mixed
Parameters
$extraFields : array<string|int, mixed>|null = null

Field names and the related key inside $serverData to be added (or just a list of field names to use the default configured $serverData mapping). If not provided it defaults to: [url, ip, http_method, server, referrer] + unique_id if present in server data

Return values
mixed

__invoke()

public __invoke(array<string|int, mixed> $record) : array<string|int, mixed>
Parameters
$record : array<string|int, mixed>
Return values
array<string|int, mixed>

The processed record

addExtraField()

public addExtraField(string $extraName, string $serverName) : self
Parameters
$extraName : string
$serverName : string
Return values
self

getSubscribedEvents()

Returns an array of event names this subscriber wants to listen to.

public static getSubscribedEvents() : array<string, string|array{0: string, 1: int}|list>

The array keys are event names and the value can be:

  • The method name to call (priority defaults to 0)
  • An array composed of the method name to call and the priority
  • An array of arrays composed of the method names to call and respective priorities, or 0 if unset

For instance:

  • ['eventName' => 'methodName']
  • ['eventName' => ['methodName', $priority]]
  • ['eventName' => [['methodName1', $priority], ['methodName2']]]

The code must not depend on runtime state as it will only be called at compile time. All logic depending on runtime state must be put into the individual methods handling the events.

Return values
array<string, string|array{0: string, 1: int}|list>

appendExtraFields()

private appendExtraFields(array<string|int, mixed> $extra) : array<string|int, mixed>
Parameters
$extra : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results