Skip to content

Commit bde5054

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

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 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,28 @@ abstract protected function getSearchFieldName(): string;
3132

3233
/**
3334
* @return array<string>
35+
*
36+
*
37+
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
3438
*/
3539
protected function getSearchFieldNames(Criterion $criterion): array
3640
{
37-
return array_keys(
41+
$searchFieldNames = array_keys(
3842
$this->fieldNameResolver->getFieldTypes(
3943
$criterion,
4044
$criterion->target,
4145
$this->imageFieldType->getFieldTypeIdentifier(),
4246
$this->getSearchFieldName()
4347
)
4448
);
49+
50+
if (empty($searchFieldNames)) {
51+
throw new InvalidArgumentException(
52+
'$criterion->target',
53+
"No searchable Fields found for the provided Criterion target '{$criterion->target}'."
54+
);
55+
}
56+
57+
return $searchFieldNames;
4558
}
4659
}

0 commit comments

Comments
 (0)