How could I use call_func_array to create a new object with a __construct method (with some not optional arguments).
Here’s the code:
$urls = array(
'view' => array(
'view/(\d+)',
array('controller' => 'test', 'action' => 'view'),
array(1 => 'id'),
),
);
foreach ($urls as $name => $args) {
$route = call_user_func_array(Zend_Controller_Router_Route_Regex, $args);
$router->addRoute($name, $route);
}
The signature for the constructor is
Thus, I would have an array with the empty arguments, and merge that with the actual arguments for each router in your loop. If you want to make it simple to specify only the last option, then use string keys in your config array, and in your default array.