/** * {@inheritdoc} */ public function getFields($extract = TRUE) { if ($extract && !$this->fieldsExtracted) { $data_type_fallback_mapping = Utility::getDataTypeFallbackMapping($this->index); foreach (array(NULL, $this->getDatasourceId()) as $datasource_id) { $fields_by_property_path = array(); foreach ($this->index->getFieldsByDatasource($datasource_id) as $field_id => $field) { // Don't overwrite fields that were previously set. if (empty($this->fields[$field_id])) { $this->fields[$field_id] = clone $field; $field_data_type = $this->fields[$field_id]->getType(); // If the field data type is in the fallback mapping list, then use // the fallback type as field type. if (isset($data_type_fallback_mapping[$field_data_type])) { $this->fields[$field_id]->setType($data_type_fallback_mapping[$field_data_type]); } $fields_by_property_path[$field->getPropertyPath()] = $this->fields[$field_id]; } } if ($datasource_id && $fields_by_property_path) { try { Utility::extractFields($this->getOriginalObject(), $fields_by_property_path); } catch (SearchApiException $e) { // If we couldn't load the object, just log an error and fail // silently to set the values. watchdog_exception('search_api', $e); } } } $this->fieldsExtracted = TRUE; } return $this->fields; }