UnionOfRAD/lithium — Issue #317: Allow closure usage in Dispatcher::config()
Author: josegonzalez
Created: 2012-02-08 15:46:30+00:00
State: open

It would be a nice addition to the Dispatcher::config() call to support closures. A possible use case would be to optionally modify the request to add a parameter if there exists a file in a certain path. For example, we might add a `'maintenance' => true` flag if `/tmp/play-dead` exists, but only for a certain prefix

Dispatcher::config(array('rules' => array(
'admin' => function ($params) {
if (file_exists('/tmp/play-dead')) $params['maintenance'] = true;
return $params;
}
)));

This is a trivial example, but I'm sure more useful ways of using this feature could arise. Thoughts?