eZ\Publish\Core\Search\Common\FieldRegistry::getType PHP Méthode

getType() public méthode

Get Indexable type.
public getType ( string $name ) : eZ\Publish\SPI\FieldType\Indexable
$name string
Résultat eZ\Publish\SPI\FieldType\Indexable
    public function getType($name)
    {
        if (!isset($this->types[$name])) {
            throw new \OutOfBoundsException("No type registered for {$name}.");
        }
        return $this->types[$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\FieldRegistry::getType