- Added SearchRequest compatibilty and began working on QueryBuilder processing
This commit is contained in:
1 parent
ce4d6cdf7c
commit
4e120cea6c
20 files changed
+510
-141
No files matched your search
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Api\SearchRequest;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Ulmus\{Api\SearchRequest\Attribute\BindParameter,
|
||||
Repository,
|
||||
SearchRequest\SearchMethodEnum,
|
||||
SearchRequest\SearchRequest,
|
||||
SearchRequest\SearchRequestFromRequestTrait,
|
||||
SearchRequest\SearchRequestInterface,
|
||||
SearchRequest\SearchRequestPaginationTrait};
|
||||
|
||||
class ApiSearchRequest extends SearchRequest implements SearchRequestInterface
|
||||
{
|
||||
use SearchRequestPaginationTrait, SearchRequestFromRequestTrait {
|
||||
parseAttributeMethod as parseAttributeMethodParent;
|
||||
}
|
||||
|
||||
protected array $bindings = [];
|
||||
|
||||
public function bindings(): iterable
|
||||
{
|
||||
return array_filter($this->bindings + [
|
||||
|
||||
], fn($i) => !is_null($i)) + [];
|
||||
}
|
||||
|
||||
protected function parseAttributeMethod(object $attribute, string $field, string $propertyName,): void
|
||||
{
|
||||
switch ($attribute->method) {
|
||||
case SearchMethodEnum::Manual:
|
||||
if ($attribute instanceof BindParameter) {
|
||||
$this->bindings[$field] = $this->$propertyName;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->parseAttributeMethodParent($attribute, $field, $propertyName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Ulmus\Api\SearchRequest\Attribute;
|
||||
|
||||
use Ulmus\SearchRequest\{ SearchMethodEnum, Attribute\SearchParameter };
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||
class BindParameter extends SearchParameter
|
||||
{
|
||||
public function __construct(
|
||||
public ? string $parameter = null,
|
||||
public ? string $field = null,
|
||||
public bool $toggle = false,
|
||||
public SearchMethodEnum $method = SearchMethodEnum::Manual,
|
||||
) {}
|
||||
}
|
||||
Reference in new issue
Block a user