Skip to content

Commit aa82131

Browse files
committed
Added exception throwing when searchFileNames array is empty
1 parent f94bd5a commit aa82131

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/lib/Query/Image/CriterionVisitor/AbstractImageVisitor.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion;
1212
use Ibexa\Contracts\Solr\Query\CriterionVisitor;
13+
use Ibexa\Core\Base\Exceptions\InvalidArgumentException;
1314
use Ibexa\Core\FieldType\Image\Type;
1415
use Ibexa\Core\Search\Common\FieldNameResolver;
1516

@@ -31,16 +32,27 @@ abstract protected function getSearchFieldName(): string;
3132

3233
/**
3334
* @return array<string>
35+
*
36+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
3437
*/
3538
protected function getSearchFieldNames(Criterion $criterion): array
3639
{
37-
return array_keys(
40+
$searchFieldNames = array_keys(
3841
$this->fieldNameResolver->getFieldTypes(
3942
$criterion,
4043
$criterion->target,
4144
$this->imageFieldType->getFieldTypeIdentifier(),
4245
$this->getSearchFieldName()
4346
)
4447
);
48+
49+
if (empty($searchFieldNames)) {
50+
throw new InvalidArgumentException(
51+
'$criterion->target',
52+
"No searchable Fields found for the provided Criterion target '{$criterion->target}'."
53+
);
54+
}
55+
56+
return $searchFieldNames;
4557
}
4658
}

0 commit comments

Comments
 (0)