47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?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|\Stringable $field, string $propertyName) : void
|
|
{
|
|
switch ($attribute->method) {
|
|
case SearchMethodEnum::Where:
|
|
case SearchMethodEnum::Manual:
|
|
if ($attribute instanceof BindParameter) {
|
|
if (isset($this->$propertyName)) {
|
|
$this->bindings[(string)$field] = $this->$propertyName;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
default:
|
|
$this->parseAttributeMethodParent($attribute, $field, $propertyName);
|
|
break;
|
|
}
|
|
}
|
|
} |