Oihana PHP

PrepareActive

Prepares the `active` flag of a controller request.

This trait reads the ControllerParam::ACTIVE value and encapsulates the convention used to disable it: the flag stays at its default (or the value carried by the route arguments) unless the request supplies a query parameter whose value is one of 0, false or FALSE, in which case the flag becomes false.

Only the query string is inspected (the request body is ignored).

Tags
author

Marc Alcaraz (ekameleon)

since
1.0.0

Table of Contents

Methods

prepareActive()  : bool|null
Prepares and returns the `active` flag.

Methods

prepareActive()

Prepares and returns the `active` flag.

protected prepareActive(ServerRequestInterface|null $request[, array<string|int, mixed> $args = [] ][, bool $defaultValue = true ]) : bool|null

The value resolves to the ControllerParam::ACTIVE entry of $args (or $defaultValue when absent), and is forced to false only when the request carries an active query parameter equal to 0, false or FALSE.

Parameters
$request : ServerRequestInterface|null

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

$args : array<string|int, mixed> = []

The route/controller arguments that may carry an initial active value.

$defaultValue : bool = true

The value used when neither the arguments nor the request define the flag.

Return values
bool|null

The resolved active flag.

On this page

Search results