Hi All,
i'm thinking about to enhance the Request class to fetch nested array
elements directly. And I'm not sure if this should be implemented because of
the needed overhead. But maybe you want this :-)
For example if you have a session/post/cookie variable
$modXSettings = array(
"foo" => array(
"name" => "Peter",
"other" => "Pan"
),
perms => "god"
);
and you need only the value $modXSettings['foo']['name'] you currently have
to do this:
$tmp = $Request->GetVar('modXSettings', 'SESSION');
$name =& $tmp['foo']['name'];
nice to have would be something like this:
$name = $Request->GetVar('modXSettings[foo][name]', 'SESSION');
but the logic to implement this would cause a descend overhead.
And with ZendEndige 2.0 real derefferencing will be possible:
$name = $Request->GetVar('modXSettings', 'SESSION')[foo][name];
What do you think? Is it worth to implement such a feauture? Im usnure.
pros:
- decoding does not have to walk the
entire array, just one element (big pro)
- simplicity
- code readbility
cons:
- code overhead
- ???
I'd love to hear your thoughts
Andi
|