function RdfMappingResourceTestBase::createEntity
Same name in other branches
- 8.9.x core/modules/rdf/tests/src/Functional/Rest/RdfMappingResourceTestBase.php \Drupal\Tests\rdf\Functional\Rest\RdfMappingResourceTestBase::createEntity()
Overrides EntityResourceTestBase::createEntity
File
-
core/
modules/ rdf/ tests/ src/ Functional/ Rest/ RdfMappingResourceTestBase.php, line 36
Class
Namespace
Drupal\Tests\rdf\Functional\RestCode
protected function createEntity() {
// Create a "Camelids" node type.
$camelids = NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
]);
$camelids->save();
// Create the RDF mapping.
$llama = RdfMapping::create([
'targetEntityType' => 'node',
'bundle' => 'camelids',
]);
$llama->setBundleMapping([
'types' => [
'sioc:Item',
'foaf:Document',
],
])
->setFieldMapping('title', [
'properties' => [
'dc:title',
],
])
->setFieldMapping('created', [
'properties' => [
'dc:date',
'dc:created',
],
'datatype' => 'xsd:dateTime',
'datatype_callback' => [
'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
],
])
->save();
return $llama;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.