eZ\Publish\Core\Search\Common\FieldNameGenerator::getName PHP Method

getName() public method

Consists of a name, and optionally field name and a content type name.
public getName ( string $name, null | string $field = null, null | string $type = null ) : string
$name string
$field null | string
$type null | string
return string
    public function getName($name, $field = null, $type = null)
    {
        return implode('_', array_filter(array($type, $field, $name)));
    }

Usage Example

 public function mapFields(Content $content, $languageCode)
 {
     $fields = [];
     $contentType = $this->contentTypeHandler->load($content->versionInfo->contentInfo->contentTypeId);
     foreach ($content->fields as $field) {
         if ($field->languageCode !== $languageCode) {
             continue;
         }
         foreach ($contentType->fieldDefinitions as $fieldDefinition) {
             if ($fieldDefinition->id !== $field->fieldDefinitionId) {
                 continue;
             }
             $fieldType = $this->fieldRegistry->getType($field->type);
             $indexFields = $fieldType->getIndexData($field, $fieldDefinition);
             foreach ($indexFields as $indexField) {
                 if ($indexField->value === null) {
                     continue;
                 }
                 $documentField = new Field($name = $this->fieldNameGenerator->getName($indexField->name, $fieldDefinition->identifier, $contentType->identifier), $indexField->value, $indexField->type);
                 $this->appendField($fields, $fieldDefinition, $documentField);
             }
         }
     }
     return $fields;
 }
All Usage Examples Of eZ\Publish\Core\Search\Common\FieldNameGenerator::getName