function RdfMappingTest::createEntity
Same name in other branches
- 9 core/modules/rdf/tests/src/Functional/Jsonapi/RdfMappingTest.php \Drupal\Tests\rdf\Functional\Jsonapi\RdfMappingTest::createEntity()
Overrides ResourceTestBase::createEntity
File
-
core/
modules/ jsonapi/ tests/ src/ Functional/ RdfMappingTest.php, line 53
Class
- RdfMappingTest
- JSON:API integration test for the "RdfMapping" config entity type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
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.