function DBManager::importByFilePath in Content Export YAML 8
File
- modules/
manager_content_export_yaml/ src/ DBManager.php, line 95
Class
Namespace
Drupal\content_export_yamlCode
function importByFilePath($file) {
$parsed = new Parser();
$path_file = DRUPAL_ROOT . $file;
$status = 0;
if (file_exists($path_file)) {
$item_yaml = file_get_contents($path_file, FILE_USE_INCLUDE_PATH);
$item_object = $parsed
->parse($item_yaml, SymfonyYaml::PARSE_OBJECT);
if (is_object($item_object)) {
$new_item = $item_object
->createDuplicate();
$status = $new_item
->save();
if ($status == 1) {
$entity_type = $new_item
->getEntityTypeId();
$type = $new_item
->bundle();
$id = $new_item
->id();
$this
->export($id, $entity_type, $type);
$this
->delete($file);
}
}
}
return $status;
}