public function DefaultContentManager::generateEntity in Default Content 8
1 call to DefaultContentManager::generateEntity()
- DefaultContentManager::importContent in src/
DefaultContentManager.php - Imports default content for a given module.
File
- src/
DefaultContentManager.php, line 368 - Contains \Drupal\defaultcontent\DefaultContentManager. @todo remove all references to linkmanager?
Class
- DefaultContentManager
- A service for handling import of default content. @todo throw useful exceptions
Namespace
Drupal\defaultcontentCode
public function generateEntity($file, $entity_type_id) {
$resource = $this->resourcePluginManager
->getInstance([
'id' => 'entity:' . $entity_type_id,
]);
$entity = $this->serializer
->deserialize($this
->parseFile($file), $resource
->getPluginDefinition()['serialization_class'], 'hal_json', [
'request_method' => 'POST',
]);
$entity
->enforceIsNew(TRUE);
$entity
->setOwnerId(1);
//this would be Anonymous if done by drush
return $entity;
}