Reputation: 847
In fatfree framework, I am defining the routes in ini files. like:
GET|POST /admin/login = controllers\siteadmin\Login->index
GET|POST /admin/login/@action = controllers\siteadmin\Login->@action
Now I was wondering how to pass arguments to the functions in this setup. Also how do I set cache and ttl values for each route?
Upvotes: 4
Views: 1986
Reputation: 3908
In your .ini file, you can pass all the arguments of the route() method, separated by commas:
GET /foo=class->method //ttl=0, kbps=0
GET /foo=class->method,86400 //ttl=86400, kbps=0
GET /foo=class->method,0,56 //ttl=0, kbps=56
To pass arguments, use the following syntax:
GET /foo/@arg1/@arg2=myClass->myMethod
The method will receive the parameters as a 2nd argument:
class myClass {
function myMethod($f3,$params) {
echo $params['arg1'];
echo $params['arg2'];
}
}
Concerning the cache, it is set globally, not for each route:
[globals]
CACHE=TRUE
Upvotes: 3