public static function SolrDocumentDefinition::createFromDataType in Search API Solr 4.x
Same name and namespace in other branches
- 8.3 src/TypedData/SolrDocumentDefinition.php \Drupal\search_api_solr\TypedData\SolrDocumentDefinition::createFromDataType()
- 8.2 src/TypedData/SolrDocumentDefinition.php \Drupal\search_api_solr\TypedData\SolrDocumentDefinition::createFromDataType()
Creates a new data definition object.
This method is typically used by \Drupal\Core\TypedData\TypedDataManager::createDataDefinition() to build a definition object for an arbitrary data type. When the definition class is known, it is recommended to directly use the static create() method on that class instead; e.g.:
$map_definition = \Drupal\Core\TypedData\MapDataDefinition::create();
Parameters
string $data_type: The data type, for which a data definition should be created.
Return value
static
Throws
\InvalidArgumentException If an unsupported data type gets passed to the class; e.g., 'string' to a definition class handling 'entity:* data types.
Overrides DataDefinition::createFromDataType
File
- src/
TypedData/ SolrDocumentDefinition.php, line 40
Class
- SolrDocumentDefinition
- A typed data definition class for describing Solr documents.
Namespace
Drupal\search_api_solr\TypedDataCode
public static function createFromDataType($data_type) {
// The data type should be in the form of "solr_document:$index_id" or
// "solr_multisite_document:$index_id".
$parts = explode(':', $data_type, 2);
if (!in_array($parts[0], [
'solr_document',
'solr_multisite_document',
])) {
throw new \InvalidArgumentException('Data type must be in the form of "solr_document:INDEX_ID" or solr_multisite_document:INDEX_ID.');
}
return self::create($parts[1]);
}