com\setasign\SetaFramework\Router\Route

Callback Class Route Callback

File: /SetaFramework/src/Router/Route/Callback.php

Class hierarchy

Implements

Summary

Properties

$callback

protected callable Callback::$callback

$defaultValues

protected array<string, mixed> Callback::$defaultValues

$logger

protected ?\Psr\Log\LoggerInterface Callback::$logger

Methods

__construct()

public Callback::__construct (
callable $callback,
array<string, mixed> $defaultValues = array ( )
)

This route is for testing purposes. If you use the same callback over and over again you should create a new route.

$callback has the Request-object as param. The callback need to return an array or false. Everything what isn't an array will result a non-matching route.

Parameters
$callback : callable
 
$defaultValues : array<string, mixed>
 

match()

public Callback::match (
\Psr\Http\Message\RequestInterface $request
): ?array

Checks whether this route matches to the request

Parameters
$request : \Psr\Http\Message\RequestInterface
 
Return Values

Returns associative array(without any numeric key) with values or NULL if the route not match

setDefaultValue()

public Callback::setDefaultValue (
string $key,
mixed $value
): void

Sets a key of the defaultValues array

Parameters
$key : string

The key shouldn't be a natural number

$value : mixed
 

setDefaultValues()

public Callback::setDefaultValues (
array<string, mixed> $defaultValues
): void

Overwrites the defaultValues array

Parameters
$defaultValues : array<string, mixed>

The keys of this array shouldn't be natural numbers

setLogger()

public Callback::setLogger (
\Psr\Log\LoggerInterface $logger
): void

Sets a logger instance on the object.

Parameters
$logger : \Psr\Log\LoggerInterface