Angel S. Moreno
Angel S. Moreno

Reputation: 3961

pass named arguments from a route to a controller

Given the following Controller:

class Page { public function about($section){ switch($section){} } }

How can I pass the a value to Page->about() directly from $f3->route?

Upvotes: 0

Views: 193

Answers (1)

ikkez
ikkez

Reputation: 2052

Fat-Free will populate two parameters to each routing handler. So when you got this route: $f3->route('GET /about/@section','\Page->about'); it will call your function with 1st parameter being the framework instance and 2nd is an array of all routing arguments.

class Page { 
  public function about($f3, $args){
    switch($args['section']){} 
  } 
}

See http://fatfreeframework.com/routing-engine#RoutesandTokens for more details.

Upvotes: 2

Related Questions