How do I pass arguments in a route when defined in ini files in fatfree framework?

StackOverflow https://stackoverflow.com/questions/22529740

  •  17-06-2023
  •  | 
  •  

Вопрос

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?

Это было полезно?

Решение

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top