public function FieldsHelperInterface::createItemFromObject in Search API 8
Creates a search item object by wrapping an existing complex data object.
Parameters
\Drupal\search_api\IndexInterface $index: The item's search index.
\Drupal\Core\TypedData\ComplexDataInterface $originalObject: The original object to wrap.
string $id: (optional) The item's (combined) ID. If not set, it will be determined with the \Drupal\search_api\Datasource\DatasourceInterface::getItemId() method of $datasource. In this case, $datasource must not be NULL.
\Drupal\search_api\Datasource\DatasourceInterface|null $datasource: (optional) The datasource of the item. If not set, it will be determined from the ID and loaded from the index if needed.
Return value
\Drupal\search_api\Item\ItemInterface A search item with the given values.
Throws
\InvalidArgumentException Thrown if both $datasource and $id are NULL.
1 method overrides FieldsHelperInterface::createItemFromObject()
- FieldsHelper::createItemFromObject in src/
Utility/ FieldsHelper.php - Creates a search item object by wrapping an existing complex data object.
File
- src/
Utility/ FieldsHelperInterface.php, line 199
Class
- FieldsHelperInterface
- Provides an interface for implementations of the fields helper service.
Namespace
Drupal\search_api\UtilityCode
public function createItemFromObject(IndexInterface $index, ComplexDataInterface $originalObject, $id = NULL, DatasourceInterface $datasource = NULL);