-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(search): Allow multiple search terms in UnifiedController
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
- Loading branch information
Showing
19 changed files
with
865 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OC\Search\Filter; | ||
|
||
use OC\Search\SingleFilter; | ||
|
||
class BoolFilter extends SingleFilter { | ||
private bool $value; | ||
|
||
protected function set(string $value): void { | ||
$this->value = match ($value) { | ||
'true', 'yes', 'y', '1' => true, | ||
'false', 'no', 'n', '0', '' => false, | ||
}; | ||
} | ||
|
||
public function get(): bool { | ||
return $this->value; | ||
} | ||
|
||
public static function type(): string { | ||
return 'bool'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OC\Search\Filter; | ||
|
||
use DateTimeImmutable; | ||
use OC\Search\SingleFilter; | ||
|
||
class DateTimeFilter extends SingleFilter { | ||
private DateTimeImmutable $value; | ||
|
||
protected function set(string $value): void { | ||
if (filter_var($value, FILTER_VALIDATE_INT)) { | ||
$value = '@'.$value; | ||
} | ||
|
||
$this->value = new DateTimeImmutable($value); | ||
} | ||
|
||
public function get(): DateTimeImmutable { | ||
return $this->value; | ||
} | ||
|
||
public static function type(): string { | ||
return 'datetime'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OC\Search\Filter; | ||
|
||
use OC\Search\InvalidFilter; | ||
use OC\Search\SingleFilter; | ||
|
||
class FloatFilter extends SingleFilter { | ||
private float $value; | ||
|
||
protected function set(string $value): void { | ||
$this->value = filter_var($value, FILTER_VALIDATE_FLOAT); | ||
if ($this->value === false) { | ||
throw new InvalidFilter($value); | ||
} | ||
} | ||
|
||
public function get(): float { | ||
return $this->value; | ||
} | ||
|
||
public static function type(): string { | ||
return 'float'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OC\Search\Filter; | ||
|
||
use OC\Search\InvalidFilter; | ||
use OC\Search\SingleFilter; | ||
|
||
class IntFilter extends SingleFilter { | ||
private int $value; | ||
|
||
protected function set(string $value): void { | ||
$this->value = filter_var($value, FILTER_VALIDATE_INT); | ||
if ($this->value === false) { | ||
throw new InvalidFilter($value); | ||
} | ||
} | ||
|
||
public function get(): int { | ||
return $this->value; | ||
} | ||
|
||
public static function type(): string { | ||
return 'int'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OC\Search\Filter; | ||
|
||
use OC\Search\InvalidFilter; | ||
use OC\Search\MultiFilter; | ||
|
||
class MultiStringFilter extends MultiFilter { | ||
/** | ||
* @var string[] | ||
*/ | ||
private array $values; | ||
|
||
protected function set(string ...$values): void { | ||
$this->values = array_unique(array_filter($values)); | ||
if (empty($this->values)) { | ||
throw new InvalidFilter($values); | ||
} | ||
} | ||
|
||
public function get(): array { | ||
return $this->values; | ||
} | ||
|
||
public static function type(): string { | ||
return 'string'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright 2023 Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @author Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OC\Search\Filter; | ||
|
||
use OC\Search\InvalidFilter; | ||
use OC\Search\SingleFilter; | ||
|
||
class StringFilter extends SingleFilter { | ||
private string $value; | ||
|
||
protected function set(string $value): void { | ||
if ($value === '') { | ||
throw new InvalidFilter($value); | ||
} | ||
$this->value = $value; | ||
} | ||
|
||
public function get(): string { | ||
return $this->value; | ||
} | ||
|
||
public static function type(): string { | ||
return 'string'; | ||
} | ||
} |
Oops, something went wrong.