Oihana PHP

PrepareTimezone

Prepares the `timezone` parameter of a controller request.

This trait builds a DateTimeZone from the ControllerParam::TIMEZONE request value, falling back to the ControllerParam::TIMEZONE_DEFAULT entry of $timeOptions and then to $defaultValue. The resulting object is assigned to the referenced $timezone variable and mirrored into the parameter bag.

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Methods

prepareTimezone()  : void
Prepare the timezone component.

Methods

prepareTimezone()

Prepare the timezone component.

protected prepareTimezone(ServerRequestInterface|null $request, array<string|int, mixed>|null &$params, string|null &$timezone, array<string|int, mixed>|null $timeOptions[, string $defaultValue = 'Europe/Paris' ]) : void
Parameters
$request : ServerRequestInterface|null

The incoming PSR-7 server request, or null when no request context is available.

$params : array<string|int, mixed>|null

A reference to the parameter bag updated in place with the resolved DateTimeZone.

$timezone : string|null

A reference to the timezone holder assigned in place with the built DateTimeZone.

$timeOptions : array<string|int, mixed>|null

The time configuration providing the default timezone entry.

$defaultValue : string = 'Europe/Paris'

The fallback timezone identifier used when none is supplied (defaults to Europe/Paris).

Tags
throws
Exception

If the resolved identifier is not a valid timezone accepted by DateTimeZone.

On this page

Search results