Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-6601: Fixed wrong documentation for Indexable/Unindexed #283

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10370,16 +10370,6 @@ parameters:
count: 1
path: src/lib/FieldType/Time/Value.php

-
message: "#^Method Ibexa\\\\Core\\\\FieldType\\\\Unindexed\\:\\:getDefaultMatchField\\(\\) should return string but returns null\\.$#"
count: 1
path: src/lib/FieldType/Unindexed.php

-
message: "#^Method Ibexa\\\\Core\\\\FieldType\\\\Unindexed\\:\\:getDefaultSortField\\(\\) should return string but returns null\\.$#"
count: 1
path: src/lib/FieldType/Unindexed.php

-
message: "#^Access to an undefined property Ibexa\\\\Contracts\\\\Core\\\\FieldType\\\\Value\\:\\:\\$text\\.$#"
count: 1
Expand Down
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
8 changes: 3 additions & 5 deletions src/lib/FieldType/Unindexed.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
use Ibexa\Contracts\Core\Persistence\Content\Type\FieldDefinition;

/**
* Indexable definition for string field type.
* Empty implementation of \Ibexa\Contracts\Core\FieldType\Indexable.
*
* Used when field type doesn't contribute to search index.
*/
class Unindexed implements Indexable
{
Expand All @@ -31,8 +33,6 @@ public function getIndexDefinition()
* As field types can index multiple fields (see MapLocation field type's
* implementation of this interface), this method is used to define default
* field for matching. Default field is typically used by Field criterion.
*
* @return string
*/
public function getDefaultMatchField()
{
Expand All @@ -45,8 +45,6 @@ public function getDefaultMatchField()
* As field types can index multiple fields (see MapLocation field type's
* 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
*/
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
Loading