Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/Model/Search/Modifier/Filter/FieldType/MultiSelectFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@
namespace Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\Filter\FieldType;

use Pimcore\Bundle\GenericDataIndexBundle\Model\Search\Modifier\SearchModifierInterface;
use Pimcore\ValueObject\Collection\ArrayOfStrings;
use ValueError;

final readonly class MultiSelectFilter implements SearchModifierInterface
{
private ArrayOfStrings $values;

public function __construct(
private string $field,
array $values,
private array $values,
private bool $enablePqlFieldNameResolution = true,
) {
$this->values = new ArrayOfStrings($values);
$this->validate();
}

public function getField(): string
Expand All @@ -35,11 +33,25 @@ public function getField(): string

public function getValues(): array
{
return $this->values->getValue();
return $this->values;
}

public function isPqlFieldNameResolutionEnabled(): bool
{
return $this->enablePqlFieldNameResolution;
}

private function validate(): void
{
foreach ($this->values as $value) {
if (!is_string($value) && !is_int($value) && !is_float($value)) {
throw new ValueError(
sprintf(
'Provided array must contain only string, int or float values. (%s given)',
gettype($value)
),
);
}
}
}
}