Skip to content

Commit

Permalink
Merge pull request #19 from punktDeForks/fix/filter-view-helper
Browse files Browse the repository at this point in the history
BUGFIX: Make filter view helper work in Neos 7
  • Loading branch information
skurfuerst authored May 10, 2022
2 parents b7ed08a + 64dde61 commit 9d7f4af
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Classes/ViewHelpers/Widget/Controller/FilterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function indexAction($filterValue = '')
$query = clone $this->objects->getQuery();
$constraintSoFar = $query->getConstraint();

$filterConstraint = $query->like($this->filterProperty, $filterValue . '%');
$filterConstraint = $query->like($this->filterProperty, '%' . $filterValue . '%');

if ($constraintSoFar) {
$query->matching($query->logicalAnd($constraintSoFar, $filterConstraint));
Expand Down
24 changes: 12 additions & 12 deletions Classes/ViewHelpers/Widget/FilterViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Exception\InfiniteLoopException;
use Neos\Flow\Mvc\Exception\StopActionException;
use Neos\Flow\Persistence\QueryResultInterface;
use Neos\FluidAdaptor\Core\Widget\AbstractWidgetViewHelper;
use Neos\FluidAdaptor\Core\Widget\Exception\InvalidControllerException;
use Neos\FluidAdaptor\Core\Widget\Exception\MissingControllerException;
Expand All @@ -18,7 +17,7 @@
* <crud:widget.filter objects="{blogs}" as="filteredBlogs" filterProperty="author">
* // use {filteredBlogs} as you used {blogs} before, most certainly inside
* // a <f:for> loop.
* </f:widget.paginate>
* </crud:widget.filter>
* </code>
*
* @api
Expand All @@ -31,22 +30,23 @@ class FilterViewHelper extends AbstractWidgetViewHelper
*/
protected $controller;

public function initializeArguments():void
{
$this->registerArgument('objects', 'object', 'a QueryResultInterface of the objects to filter on', true);
$this->registerArgument('as', 'string', 'variable as which the filtered list will be available', true);
$this->registerArgument('filterProperty', 'string', 'which property to filter on', true);
$this->registerArgument('filterPlaceholder', 'string', 'placeholder to display in the filter input field', false, null);
}

/**
* Render this view helper
*
* @param QueryResultInterface $objects the objects to filter on
* @param string $as variable as which the filtered list will be available
* @param string $filterProperty which property to filter on
* @param string $filterPlaceholder placeholder to display in the filter input field
* @return string
* @throws InfiniteLoopException
* @throws StopActionException
* @throws InvalidControllerException
* @throws MissingControllerException
* @throws StopActionException
*/
public function render(QueryResultInterface $objects, $as, $filterProperty, $filterPlaceholder = NULL)
public function render(): string
{
$response = $this->initiateSubRequest();
return $response->getContent();
return $this->initiateSubRequest();
}
}

0 comments on commit 9d7f4af

Please sign in to comment.