- Fixed some bugs regarding parameter binding
This commit is contained in:
parent
0550036fd9
commit
b1adf5a086
@ -28,7 +28,7 @@ class ApiRepository extends \Ulmus\Repository
|
|||||||
|
|
||||||
public ResponseInterface $lastResponse;
|
public ResponseInterface $lastResponse;
|
||||||
|
|
||||||
public function __construct(string $entity, string $alias = self::DEFAULT_ALIAS, ConnectionAdapter $adapter = null)
|
public function __construct(string $entity, string $alias = self::DEFAULT_ALIAS, null|ConnectionAdapter $adapter = null)
|
||||||
{
|
{
|
||||||
parent::__construct($entity, $alias, $adapter);
|
parent::__construct($entity, $alias, $adapter);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,7 @@ class Filter extends Fragment
|
|||||||
|
|
||||||
public function add($field, mixed $value) : self
|
public function add($field, mixed $value) : self
|
||||||
{
|
{
|
||||||
$this->conditionList[$field] = $value;
|
$this->conditionList[(string) $field] = $value;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ use Ulmus\{Api\SearchRequest\Attribute\BindParameter,
|
|||||||
|
|
||||||
class ApiSearchRequest extends SearchRequest implements SearchRequestInterface
|
class ApiSearchRequest extends SearchRequest implements SearchRequestInterface
|
||||||
{
|
{
|
||||||
use SearchRequestPaginationTrait, SearchRequestFromRequestTrait {
|
use /*SearchRequestPaginationTrait,*/ SearchRequestFromRequestTrait {
|
||||||
parseAttributeMethod as parseAttributeMethodParent;
|
parseAttributeMethod as parseAttributeMethodParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,14 +26,18 @@ class ApiSearchRequest extends SearchRequest implements SearchRequestInterface
|
|||||||
], fn($i) => !is_null($i)) + [];
|
], fn($i) => !is_null($i)) + [];
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function parseAttributeMethod(object $attribute, string $field, string $propertyName,): void
|
protected function parseAttributeMethod(object $attribute, string|\Stringable $field, string $propertyName) : void
|
||||||
{
|
{
|
||||||
switch ($attribute->method) {
|
switch ($attribute->method) {
|
||||||
|
case SearchMethodEnum::Where:
|
||||||
case SearchMethodEnum::Manual:
|
case SearchMethodEnum::Manual:
|
||||||
if ($attribute instanceof BindParameter) {
|
if ($attribute instanceof BindParameter) {
|
||||||
$this->bindings[$field] = $this->$propertyName;
|
if (isset($this->$propertyName)) {
|
||||||
|
$this->bindings[(string)$field] = $this->$propertyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$this->parseAttributeMethodParent($attribute, $field, $propertyName);
|
$this->parseAttributeMethodParent($attribute, $field, $propertyName);
|
||||||
|
|||||||
@ -2,15 +2,20 @@
|
|||||||
|
|
||||||
namespace Ulmus\Api\SearchRequest\Attribute;
|
namespace Ulmus\Api\SearchRequest\Attribute;
|
||||||
|
|
||||||
use Ulmus\SearchRequest\{ SearchMethodEnum, Attribute\SearchParameter };
|
use Ulmus\SearchRequest\{Attribute\PropertyValueSource,
|
||||||
|
Attribute\SearchManual,
|
||||||
|
SearchMethodEnum,
|
||||||
|
Attribute\SearchParameter};
|
||||||
|
|
||||||
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
#[\Attribute(\Attribute::TARGET_PROPERTY)]
|
||||||
class BindParameter extends SearchParameter
|
class BindParameter extends SearchManual
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public ? string $parameter = null,
|
public null|string|array $parameter = null,
|
||||||
public ? string $field = null,
|
public null|string|\Stringable|array $field = null,
|
||||||
public bool $toggle = false,
|
public bool $toggle = false,
|
||||||
public SearchMethodEnum $method = SearchMethodEnum::Manual,
|
public SearchMethodEnum $method = SearchMethodEnum::Manual,
|
||||||
|
public string $description = "",
|
||||||
|
public PropertyValueSource|array $source = PropertyValueSource::RequestAttribute,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user