Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed search in Dynamics list #375

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Controller/DynamicController.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php

Check failure on line 1 in Controller/DynamicController.php

View workflow job for this annotation

GitHub Actions / PHP Lint

Ignored error pattern #^Parameter \#6 \$limit of class Sulu\\Component\\Rest\\ListBuilder\\ListRepresentation constructor expects int, mixed given\.$# in path /home/runner/work/SuluFormBundle/SuluFormBundle/Controller/DynamicController.php was not matched in reported errors.

/*
* This file is part of Sulu.
Expand Down Expand Up @@ -117,7 +117,7 @@
$request->get('_route'),
$request->query->all(),
$page,
$limit,

Check failure on line 120 in Controller/DynamicController.php

View workflow job for this annotation

GitHub Actions / PHP Lint

Parameter #6 $limit of class Sulu\Component\Rest\ListBuilder\ListRepresentation constructor expects int|null, mixed given.
$total
);

Expand Down Expand Up @@ -164,7 +164,7 @@
'fromDate' => $request->get('fromDate'),
'toDate' => $request->get('toDate'),
'search' => $request->get('search'),
'searchFields' => \array_filter(\explode(',', $request->get('searchFields', ''))),
'searchFields' => \array_filter(\explode(',', $request->get('fields', ''))),
];

return \array_filter($filters);
Expand Down
12 changes: 5 additions & 7 deletions Repository/DynamicRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,12 @@ protected function addSearchFilter(QueryBuilder $queryBuilder, ?string $search,

// Search each term in each search field
foreach ($terms as $counter => $term) {
$expressions = [];

foreach ($searchFields as $searchField) {
$expressions[] = $queryBuilder->expr()->like(
'dynamic.' . $searchField,
$expressions = [
$queryBuilder->expr()->like(
'dynamic.data',
':searchTerm' . $counter
);
}
),
];

$queryBuilder->andWhere(\call_user_func_array([$queryBuilder->expr(), 'orX'], $expressions));
$queryBuilder->setParameter('searchTerm' . $counter, '%' . $term . '%');
Expand Down
Loading