\Charcoal\App\RouteTemplateRoute

Template Route Handler.

A route handler is a simple invokale object with the signature: __invoke(Container $container, RequestInterface $request, ResponseInterface $response) It is only called (invoked) when a route is matched.

This is the default "Slim Route Handler" for template style routes. It uses a TemplateRouteConfig to properly either:

  • redirect the request, if explicitely set
  • load and render a "Template" object

Templates can be any objects that can be loaded with a "TemplateFactory". The Template Factory used is an external dependency (template/factory) expected to be set on the container.

Template-level cache is possible by setting the "cache" config option to true. Cached template can not have any options; they will always return the exact same content for all "template".

Summary

Methods
Properties
Constants
__construct()
createConfig()
__invoke()
No public properties found
No constants found
templateContent()
renderTemplate()
createTemplate()
parseRedirect()
cacheEnabled()
cacheTtl()
cacheIdent()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

__construct()

__construct(array  $data) 

Create new template route

Required dependencies

  • config — ScriptRouteConfig

Parameters

array $data

Dependencies.

createConfig()

createConfig(mixed|null  $data = null) : \Charcoal\App\Route\TemplateRouteConfig

ConfigurableTrait > createConfig()

Parameters

mixed|null $data

Optional config data.

Returns

\Charcoal\App\Route\TemplateRouteConfig

__invoke()

__invoke(\Pimple\Container  $container, \Psr\Http\Message\RequestInterface  $request, \Psr\Http\Message\ResponseInterface  $response) : \Psr\Http\Message\ResponseInterface

Parameters

\Pimple\Container $container

A DI (Pimple) container.

\Psr\Http\Message\RequestInterface $request

A PSR-7 compatible Request instance.

\Psr\Http\Message\ResponseInterface $response

A PSR-7 compatible Response instance.

Returns

\Psr\Http\Message\ResponseInterface

templateContent()

templateContent(\Pimple\Container  $container, \Psr\Http\Message\RequestInterface  $request) : string

Parameters

\Pimple\Container $container

A DI (Pimple) container.

\Psr\Http\Message\RequestInterface $request

The request to intialize the template with.

Returns

string

renderTemplate()

renderTemplate(\Pimple\Container  $container, \Psr\Http\Message\RequestInterface  $request) : string

Parameters

\Pimple\Container $container

A DI (Pimple) container.

\Psr\Http\Message\RequestInterface $request

The request to intialize the template with.

Returns

string

createTemplate()

createTemplate(\Pimple\Container  $container, \Psr\Http\Message\RequestInterface  $request) : string

Parameters

\Pimple\Container $container

A DI (Pimple) container.

\Psr\Http\Message\RequestInterface $request

The request to intialize the template with.

Returns

string

parseRedirect()

parseRedirect(string  $redirection, \Psr\Http\Message\RequestInterface  $request) : \Slim\Http\Uri|null

Parameters

string $redirection

The route's destination.

\Psr\Http\Message\RequestInterface $request

A PSR-7 compatible Request instance.

Returns

\Slim\Http\Uri|null

cacheEnabled()

cacheEnabled() : boolean

Returns

boolean

cacheTtl()

cacheTtl() : integer

Returns

integer

cacheIdent()

cacheIdent() : string

Returns

string