Commit ea0fd677 authored by Stefan Busemann's avatar Stefan Busemann
Browse files

Merge branch 'bugfix/search-for-personal-members-with-firstname-lastname' into 'master'

Add possibility to search for personal members (community, bronze)

See merge request t3o/t3o_membership!8
parents f4d05419 d4825a1a
...@@ -19,6 +19,7 @@ use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; ...@@ -19,6 +19,7 @@ use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
/** /**
* Class \T3oMembership\Domain\Repository\MemberRepository * Class \T3oMembership\Domain\Repository\MemberRepository
*
* @author Thomas Löffler <thomas.loeffler@typo3.org> * @author Thomas Löffler <thomas.loeffler@typo3.org>
*/ */
class MemberRepository extends \TYPO3\CMS\Extbase\Persistence\Repository class MemberRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
...@@ -27,10 +28,11 @@ class MemberRepository extends \TYPO3\CMS\Extbase\Persistence\Repository ...@@ -27,10 +28,11 @@ class MemberRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
/** /**
* @var array * @var array
*/ */
protected $defaultOrderings = array( protected $defaultOrderings = [
'membership.sorting' => QueryInterface::ORDER_ASCENDING, 'membership.sorting' => QueryInterface::ORDER_ASCENDING,
'name' => QueryInterface::ORDER_ASCENDING 'name' => QueryInterface::ORDER_ASCENDING,
); 'lastname' => QueryInterface::ORDER_ASCENDING
];
/** /**
* @param string $filterString * @param string $filterString
...@@ -40,10 +42,16 @@ class MemberRepository extends \TYPO3\CMS\Extbase\Persistence\Repository ...@@ -40,10 +42,16 @@ class MemberRepository extends \TYPO3\CMS\Extbase\Persistence\Repository
public function findByStringAndMembership($filterString, $filterMembership) public function findByStringAndMembership($filterString, $filterMembership)
{ {
$query = $this->createQuery(); $query = $this->createQuery();
$constraints = array(); $constraints = [];
if ($filterString) { if ($filterString) {
$filterString = $this->getDatabaseConnection()->escapeStrForLike($filterString, 'tx_t3omembership_domain_model_member'); $filterString = $this->getDatabaseConnection()->escapeStrForLike($filterString, 'tx_t3omembership_domain_model_member');
$constraints[] = $query->like('name', '%' . $filterString . '%'); $constraints = $query->logicalOr(
[
$query->like('name', '%' . $filterString . '%'),
$query->like('firstname', '%' . $filterString . '%'),
$query->like('lastname', '%' . $filterString . '%'),
]
);
} }
if ($filterMembership) { if ($filterMembership) {
$constraints[] = $query->equals('membership', $filterMembership); $constraints[] = $query->equals('membership', $filterMembership);
......
Supports Markdown
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