diff --git a/src/Plugin/search_api/processor/FilesFieldsProcessorPlugin.php b/src/Plugin/search_api/processor/FilesFieldsProcessorPlugin.php index 80f3189..077e2a7 100644 --- a/src/Plugin/search_api/processor/FilesFieldsProcessorPlugin.php +++ b/src/Plugin/search_api/processor/FilesFieldsProcessorPlugin.php @@ -111,11 +111,19 @@ class FilesFieldsProcessorPlugin extends ProcessorPluginBase { if ($entity->hasField($field_name)) { $filefield_values = $entity->get($field_name)->getValue(); - $all_fids = array(); - foreach ($filefield_values as $filefield_value) { - $all_fids[] = $filefield_value['target_id']; + if ($field_name != 'fid') { + $all_fids = array(); + foreach ($filefield_values as $filefield_value) { + $all_fids[] = $filefield_value['target_id']; + } + $fids = $this->limitToAllowedNumber($all_fids); + } + else { + // There's only one file in a file entity. + $fid = $filefield_values[0]['value']; + $fids = array($fid => $fid); } - $fids = $this->limitToAllowedNumber($all_fids); + // Retrieve the files. $files = \Drupal::entityTypeManager() ->getStorage('file') @@ -294,6 +302,12 @@ class FilesFieldsProcessorPlugin extends ProcessorPluginBase { $file_fields[$property->get('field_name')] = $property->get('label'); } } + // Check if it is a file entity. + if ($property->getTargetEntityTypeId() == 'file') { + if ($property->getName() == 'fid') { + $file_fields[$property->getName()] = 'File entity'; + } + } } } return $file_fields;