Home » Structures » Structures_DataGrid » Bug #3089
Structures_DataGrid_Column::formatter() does not support static method callback
Details
| Request #3089 | Structures_DataGrid_Column::formatter() does not support static method callback |
|---|---|
| Submitted | 2005-01-04 01:20 UTC |
| From | rolf at winmutt dot com |
| Assigned | asnagy |
| Status | Bogus |
| Package | Structures_DataGrid |
| PHP Version | 5.0.3 |
| OS | Linux 2.6 |
| Roadmaps | (Not assigned) |
Comments
[2005-01-04 01:20 UTC] rolf at winmutt dot com
Description:
------------
When passing array('class','method') to formatter it does not allow you to pass any type of additional arguments. It would be nice to do so.
[2005-01-04 03:59 UTC] winmutt at winmutt dot com
snowcrash DataGrid # diff Column.php ~winmutt/pear/Structures_DataGrid/DataGrid/Column.php
186,189c186
< } elseif (is_array($this->formatter) && is_array($this->formatter[0])) {
< $formatter = $this->formatter[0];
< $paramList = array_merge($this->formatter[1], $record);
< } else {
---
> } else {
196c193
< $result = call_user_func($formatter, ($paramList?$paramList:$record));
---
> $result = call_user_func($formatter, $paramList);
[2005-01-05 19:16 UTC] asnagy at webitecture dot org
I am curious as to why you would want to pass an array of class and method?
The code supports both syntaxes:
$class->method() and
Class::method()
For example:
$dg->addColumn(new Structures_DataGrid_Column('Edit', null, null, array('align' => 'center'), null, Printer::printLink($label=Edit)');
Please explain your reasoning better
[2005-01-07 00:40 UTC] winmutt at winmutt dot com
The problem is passing more complex paramaters to the
callback function. If I want to pass an object or complex
array, the current string parsing failes.
[2005-01-10 15:24 UTC] asnagy at webitecture dot org
Yes, you can't pass parameters into a callback array.
Try something like this:
$callback = 'Printer::printLink($label=Edit, $foo=Bar, $name=John Doe)';
$dg->addColumn(new Structures_DataGrid_Column('Edit', null, null, array('align' => 'center'), null, $callback);
This way you can call a method and pass numerous parameters.
If this is not the answer to your question, please include an example of what you are trying to do. Otherwise this bug will be closed as bogus.
[2005-01-18 17:46 UTC] asnagy at webitecture dot org
Thank you for taking the time to write to us, but this is not
a bug.
All features asked for already exists
[2005-01-19 23:57 UTC] rolf at winmutt dot com
I'm trying to pass complex data back to a callback
function in a object :
mixed call_user_func ( callback function [, mixed
parameter [, mixed ...]] )
IE :
call_user_func(array(&$bsq,'shop'),&$someobj,$cloneobj,
$somearray);
My patch listed works just fine and does not break any
existing functionality.