eZ\Publish\Core\Search\Common\FieldNameResolver::getIndexFieldName PHP Method

getIndexFieldName() public method

Returns index field name for the given parameters.
public getIndexFieldName ( object $criterionOrSortClause, string $contentTypeIdentifier, string $fieldDefinitionIdentifier, string $fieldTypeIdentifier, string $name, boolean $isSortField ) : string
$criterionOrSortClause object
$contentTypeIdentifier string
$fieldDefinitionIdentifier string
$fieldTypeIdentifier string
$name string
$isSortField boolean
return string
    public function getIndexFieldName($criterionOrSortClause, $contentTypeIdentifier, $fieldDefinitionIdentifier, $fieldTypeIdentifier, $name, $isSortField)
    {
        // If criterion or sort clause implements CustomFieldInterface and custom field is set for
        // ContentType/FieldDefinition, return it
        if ($criterionOrSortClause instanceof CustomFieldInterface && ($customFieldName = $criterionOrSortClause->getCustomField($contentTypeIdentifier, $fieldDefinitionIdentifier))) {
            return [$customFieldName => null];
        }
        // Else, generate field name from field type's index definition
        $indexFieldType = $this->fieldRegistry->getType($fieldTypeIdentifier);
        // If $name is not given use default field name
        if ($name === null) {
            if ($isSortField) {
                $name = $indexFieldType->getDefaultSortField();
            } else {
                $name = $indexFieldType->getDefaultMatchField();
            }
        }
        $indexDefinition = $indexFieldType->getIndexDefinition();
        // Should only happen by mistake, so let's throw if it does
        if (!isset($indexDefinition[$name])) {
            throw new RuntimeException("Could not find '{$name}' field in '{$fieldTypeIdentifier}' field type's index definition");
        }
        $field = $this->nameGenerator->getTypedName($this->nameGenerator->getName($name, $fieldDefinitionIdentifier, $contentTypeIdentifier), $indexDefinition[$name]);
        return [$field => $indexDefinition[$name]];
    }