mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-18 10:16:49 +00:00
Small improvements in the search [skip ci]
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
* See the LICENSE file for details.
|
* See the LICENSE file for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare(strict_types = 1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace FireflyIII\Support\Search;
|
namespace FireflyIII\Support\Search;
|
||||||
|
|
||||||
@@ -37,6 +37,8 @@ class Search implements SearchInterface
|
|||||||
private $limit = 100;
|
private $limit = 100;
|
||||||
/** @var Collection */
|
/** @var Collection */
|
||||||
private $modifiers;
|
private $modifiers;
|
||||||
|
/** @var string */
|
||||||
|
private $originalQuery = '';
|
||||||
/** @var User */
|
/** @var User */
|
||||||
private $user;
|
private $user;
|
||||||
/** @var array */
|
/** @var array */
|
||||||
@@ -58,7 +60,10 @@ class Search implements SearchInterface
|
|||||||
*/
|
*/
|
||||||
public function getWordsAsString(): string
|
public function getWordsAsString(): string
|
||||||
{
|
{
|
||||||
return join(' ', $this->words);
|
$string = join(' ', $this->words);
|
||||||
|
if (strlen($string) === 0) {
|
||||||
|
return $this->originalQuery;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -74,9 +79,10 @@ class Search implements SearchInterface
|
|||||||
*/
|
*/
|
||||||
public function parseQuery(string $query)
|
public function parseQuery(string $query)
|
||||||
{
|
{
|
||||||
$filteredQuery = $query;
|
$filteredQuery = $query;
|
||||||
$pattern = '/[a-z_]*:[0-9a-z-.]*/i';
|
$this->originalQuery = $query;
|
||||||
$matches = [];
|
$pattern = '/[a-z_]*:[0-9a-z-.]*/i';
|
||||||
|
$matches = [];
|
||||||
preg_match_all($pattern, $query, $matches);
|
preg_match_all($pattern, $query, $matches);
|
||||||
|
|
||||||
foreach ($matches[0] as $match) {
|
foreach ($matches[0] as $match) {
|
||||||
|
Reference in New Issue
Block a user