It'd be awesome if you could do something like this in menu definitions:
$items['thing/new'] = array(
'title' => 'New thing',
'page callback' => 'my_thing_form',
'page arguments' => array(function() { return new MyThing; }),
);
$items['thing/%mything'] = array(
'title' => 'New thing',
'page callback' => 'my_thing_form',
'page arguments' => array(2),
);
And in turn the menu system could check to see if a given argument is callable and if so, call it when preparing the args. We already special case some things passed to arguments, i.e. integers correspond to parts of a path if load functions are defined.
But alas, closures can't be serialized :(
Or can they?
I know this is a pretty crazy request, but I think it would really make module coding alot cleaner by allowing closures in more places where we currently would have to rely on a separate procedural function for a simple 1 liner, and then in turn reference the name of that function in a string.
Any thoughts?
Comments
Comment #13
smustgrave commentedThank you for posting
As it's been 11 years wonder if this is still a desired feature?
Thanks!
Comment #15
quietone commentedNearly another two years and there is no discussion or support for this idea.
The proposal doesn't met the Criteria for evaluating proposed changes. In this case, there is not demonstrated demand and support for the change.
If there is interest in this re-open the issue and add a comment. Or open a new issue and reference this one.