Closed mrceperka closed 7 years ago
Got pull request ready with this one line fix.
Bump. What do u think @paveljanda ?
@mrceperka Why don't you just return the filtered array in you condition callback?
How would that help? It is all based on modifying existing data_source
.
I do not see any
$this->data_source = Callback::invokeArgs(...)
Right. Do this than:
Filter::setCondition(function(& $data, $value) { ... });
I should mention that in docu. Hmmm
that will probably yell at me, that variable that i am expecting is not passed via refference...
It doesn't work in PHP like that (It's not actually a reference to some memory block)
<?php
function fooMe(& $foo)
{
$foo = 'foo';
}
$a = 'a';
fooMe($a);
echo $a; // foo
Fine, I've propably did not try this little hack of yours. Thank you.
Well it's not a hack. :D
It's just that I am trying to make it work similar way as the fluent interface of Dibi\Fluent and other objects that change themselves with every method called above them.
Yes, I've seen those 'self mutating' collections. Better approach is returning new collection. But this is propably better (or easier?) solution for compatibility. Or you can CLONE them all :D
Hi, I have
data_source
which is anarray
. I've usedsetCondition
atfilter
component for custom filtering.Now, because my
data_source
isarray
, it will not be passed asobject
would. Hotfix is easy, just add&
before$this->data_source
.array
data_source
toobject
just because of this?Or, you could stop mutating the dara source with callback and instead require it to return new
data_source
...