Documentation

Filters
in package

Filters

Table of Contents

$arguments  : array<string|int, mixed>
Any arguments to be passed to filters.
$argumentsClass  : array<string|int, mixed>
Any arguments to be passed to filtersClass.
$config  : Filters
The original config file
$filters  : array<string|int, mixed>
The processed filters that will be used to check against.
$filtersClass  : array<string|int, mixed>
The collection of filters' class names that will be used to execute in each position.
$initialized  : bool
Whether we've done initial processing on the filter lists.
$modules  : Modules
Handle to the modules config.
$request  : RequestInterface
The active IncomingRequest or CLIRequest
$response  : ResponseInterface
The active Response instance
__construct()  : mixed
Constructor.
addFilter()  : $this
Adds a new alias to the config file.
enableFilter()  : Filters
Ensures that a specific filter is on and enabled for the current request.
getArguments()  : mixed
Returns the arguments for a specified key, or all.
getFilters()  : array<string|int, mixed>
Returns the processed filters array.
getFiltersClass()  : array<string|int, mixed>
Returns the filtersClass array.
initialize()  : Filters
Runs through our list of filters provided by the configuration object to get them ready for use, including getting uri masks to proper regex, removing those we can from the possibilities based on HTTP method, etc.
reset()  : $this
Restores instance to its pre-initialized state.
run()  : RequestInterface|ResponseInterface|mixed
Runs through all of the filters for the specified uri and position.
setResponse()  : mixed
Set the response explicity.
processAliasesToClass()  : void
Maps filter aliases to the equivalent filter classes
processFilters()  : void
Add any applicable configured filters to the mix.
processGlobals()  : void
Add any applicable (not excluded) global filter settings to the mix.
processMethods()  : void
Add any method-specific filters to the mix.
discoverFilters()  : mixed
If discoverFilters is enabled in Config then system will try to auto-discover custom filters files in Namespaces and allow access to the config object via the variable $customfilters as with the routes file
pathApplies()  : bool
Check paths for match for URI

Properties

$arguments

Any arguments to be passed to filters.

protected array<string|int, mixed> $arguments = []

$argumentsClass

Any arguments to be passed to filtersClass.

protected array<string|int, mixed> $argumentsClass = []

$filters

The processed filters that will be used to check against.

protected array<string|int, mixed> $filters = ['before' => [], 'after' => []]

$filtersClass

The collection of filters' class names that will be used to execute in each position.

protected array<string|int, mixed> $filtersClass = ['before' => [], 'after' => []]

$initialized

Whether we've done initial processing on the filter lists.

protected bool $initialized = false

Methods

addFilter()

Adds a new alias to the config file.

public addFilter(string $class[, string|null $alias = null ][, string $when = 'before' ][, string $section = 'globals' ]) : $this

MUST be called prior to initialize(); Intended for use within routes files.

Parameters
$class : string
$alias : string|null = null
$when : string = 'before'
$section : string = 'globals'
Return values
$this

enableFilter()

Ensures that a specific filter is on and enabled for the current request.

public enableFilter(string $name[, string $when = 'before' ]) : Filters

Filters can have "arguments". This is done by placing a colon immediately after the filter name, followed by a comma-separated list of arguments that are passed to the filter when executed.

Parameters
$name : string
$when : string = 'before'
Return values
Filters

getArguments()

Returns the arguments for a specified key, or all.

public getArguments([string|null $key = null ]) : mixed
Parameters
$key : string|null = null
Return values
mixed

getFilters()

Returns the processed filters array.

public getFilters() : array<string|int, mixed>
Return values
array<string|int, mixed>

getFiltersClass()

Returns the filtersClass array.

public getFiltersClass() : array<string|int, mixed>
Return values
array<string|int, mixed>

initialize()

Runs through our list of filters provided by the configuration object to get them ready for use, including getting uri masks to proper regex, removing those we can from the possibilities based on HTTP method, etc.

public initialize([string $uri = null ]) : Filters

The resulting $this->filters is an array of only filters that should be applied to this request.

We go ahead an process the entire tree because we'll need to run through both a before and after and don't want to double process the rows.

Parameters
$uri : string = null
Return values
Filters

reset()

Restores instance to its pre-initialized state.

public reset() : $this

Most useful for testing so the service can be re-initialized to a different path.

Return values
$this

processAliasesToClass()

Maps filter aliases to the equivalent filter classes

protected processAliasesToClass(string $position) : void
Parameters
$position : string
Tags
throws
FilterException
Return values
void

processFilters()

Add any applicable configured filters to the mix.

protected processFilters([string $uri = null ]) : void
Parameters
$uri : string = null
Return values
void

processGlobals()

Add any applicable (not excluded) global filter settings to the mix.

protected processGlobals([string $uri = null ]) : void
Parameters
$uri : string = null
Return values
void

processMethods()

Add any method-specific filters to the mix.

protected processMethods() : void
Return values
void

discoverFilters()

If discoverFilters is enabled in Config then system will try to auto-discover custom filters files in Namespaces and allow access to the config object via the variable $customfilters as with the routes file

private discoverFilters() : mixed

Sample : $filters->aliases['custom-auth'] = \Acme\Blob\Filters\BlobAuth::class;

Return values
mixed

pathApplies()

Check paths for match for URI

private pathApplies(string $uri, mixed $paths) : bool
Parameters
$uri : string

URI to test against

$paths : mixed

The path patterns to test

Return values
bool

True if any of the paths apply to the URI

Search results