Commit 2f1994ed authored by Stefan Busemann's avatar Stefan Busemann
Browse files

Merge branch '37-search-function-member-list' into 'master'

Resolve "Search function member list"

Closes #37

See merge request t3o/t3o_membership!11
parents 655bd4e7 5a886cd2
<?php
namespace T3o\T3oMembership\Domain\Repository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
......@@ -39,13 +40,23 @@ class MemberRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
$query = $this->createQuery();
$constraints = [];
if ($filterString) {
$constraints = $query->logicalOr(
[
$filterStringConstraints = [
$query->like('name', '%' . $filterString . '%'),
$query->like('firstname', '%' . $filterString . '%'),
$query->like('lastname', '%' . $filterString . '%'),
]
);
];
list($firstName, $lastName) = GeneralUtility::trimExplode(' ', $filterString);
if(strlen($firstName) > 0 && strlen($lastName) > 0){
$filterStringConstraints[] = $query->logicalAnd(
[
$query->like('firstname', '%' . $firstName . '%'),
$query->like('lastname', '%' . $lastName . '%'),
]
);
}
$constraints[] = $query->logicalOr($filterStringConstraints);
}
if ($filterMembership) {
$constraints[] = $query->equals('membership', $filterMembership);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment