Skip to content

Commit

Permalink
Filters\Text: Added context into suggestion callback
Browse files Browse the repository at this point in the history
  • Loading branch information
o5 committed Dec 4, 2014
1 parent 9093bd4 commit 302eec9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Components/Filters/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function handleSuggest($query)
$items = $this->grid->model->suggest($column, $conditions, $this->suggestionLimit);

} else {
$items = callback($this->suggestionCallback)->invokeArgs(array($query, $actualFilter, $conditions));
$items = callback($this->suggestionCallback)->invokeArgs(array($query, $actualFilter, $conditions, $this));
if (!is_array($items)) {
throw new \Exception('Items must be an array.');
}
Expand Down
3 changes: 2 additions & 1 deletion tests/Components/Filter.Text.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ class FilterTextTest extends \Tester\TestCase

$grid->addFilterText('test', 'Test')
->setSuggestion()
->setSuggestionCallback(function($query, $filter, $conditions) {
->setSuggestionCallback(function($query, $filter, $conditions, $filterComp) use ($grid) {
Assert::same('QUERY', $query);
Assert::same(array('name' => 'aa'), $filter);
Assert::same($grid->getFilter('test'), $filterComp);

$cond = new \Grido\Components\Filters\Condition('name', 'LIKE ?', '%aa%');
Assert::same($cond->__toArray(), $conditions[0]->__toArray());
Expand Down

0 comments on commit 302eec9

Please sign in to comment.