Tonic


Tonic\Resource
src/Tonic/Resource.php at line 8

Class Resource

Resource
All Known Subclasses:
Tyrell\Hello Tyrell\Secret

public class Resource

Model a HTTP resource


Field Summary
mixed

$params

Constructor Summary
void

__construct(Application app, Request request, mixed urlParams)

Method Summary
Response

exec()

Execute the resource, that is, find the correct resource method to call based upon the request and then call it.

protected void

before(callable action)

Add a function to execute on the request before the resource method is called

protected void

after(callable action)

Add a function to execute on the response after the resource method is called

protected void

method(str method)

HTTP method condition must match request method

protected void

priority(int priority)

Higher priority method takes precident over other matches

protected void

accepts(str mimetype)

Accepts condition mimetype must match request content type

protected int

provides(str mimetype)

Provides condition mimetype must be in request accept array, returns a number based on the priority of the match.

protected int

lang(str language)

Lang condition language code must be in request accept lang array, returns a number based on the priority of the match.

protected void

cache(int length)

Set cache control header on response

Field Detail

src/Tonic/Resource.php at line 11

params

public mixed $params

Constructor Detail

src/Tonic/Resource.php at line 15

__construct

public void __construct(Application app, Request request, mixed urlParams)

Method Detail

src/Tonic/Resource.php at line 98

exec

public Response exec()

Execute the resource, that is, find the correct resource method to call based upon the request and then call it.


src/Tonic/Resource.php at line 146

before

protected void before(callable action)

Add a function to execute on the request before the resource method is called


src/Tonic/Resource.php at line 158

after

protected void after(callable action)

Add a function to execute on the response after the resource method is called


src/Tonic/Resource.php at line 169

method

protected void method(str method)

HTTP method condition must match request method


src/Tonic/Resource.php at line 179

priority

protected void priority(int priority)

Higher priority method takes precident over other matches


src/Tonic/Resource.php at line 188

accepts

protected void accepts(str mimetype)

Accepts condition mimetype must match request content type


src/Tonic/Resource.php at line 201

provides

protected int provides(str mimetype)

Provides condition mimetype must be in request accept array, returns a number based on the priority of the match.


src/Tonic/Resource.php at line 225

lang

protected int lang(str language)

Lang condition language code must be in request accept lang array, returns a number based on the priority of the match.


src/Tonic/Resource.php at line 238

cache

protected void cache(int length)

Set cache control header on response

Parameters:
length - Number of seconds to cache the response for

Tonic