Skip to content

Commit

Permalink
IBX-6601: Aligned \Ibexa\Contracts\Core\FieldType\Indexable::{getDefa…
Browse files Browse the repository at this point in the history
…ultMatchField, getDefaultSortField} allowed return types with existing implementations
  • Loading branch information
adamwojs committed Oct 11, 2023
1 parent 4eba9bc commit 402a223
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/contracts/FieldType/Indexable.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getIndexDefinition();
* implementation of this interface), this method is used to define default
* field for matching. Default field is typically used by Field criterion.
*
* @return string
* @return string|null
*/
public function getDefaultMatchField();

Expand All @@ -50,7 +50,7 @@ public function getDefaultMatchField();
* implementation of this interface), this method is used to define default
* field for sorting. Default field is typically used by Field sort clause.
*
* @return string
* @return string|null
*/
public function getDefaultSortField();
}
Expand Down
6 changes: 6 additions & 0 deletions src/lib/Search/Common/FieldNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,12 @@ public function getIndexFieldName(
$indexDefinition = $indexFieldType->getIndexDefinition();

// Should only happen by mistake, so let's throw if it does
if ($name === null) {
throw new RuntimeException(
"Undefined default sort or match field in '{$fieldTypeIdentifier}' Field Type's index definition"
);
}

if (!isset($indexDefinition[$name])) {
throw new RuntimeException(
"Could not find Field '{$name}' in '{$fieldTypeIdentifier}' Field Type's index definition"
Expand Down

0 comments on commit 402a223

Please sign in to comment.