From ecb6104bee5d71ec059f36d5ba99aa6bce6dac4c Mon Sep 17 00:00:00 2001 From: Camilo Villamizar Date: Thu, 5 Sep 2024 13:09:26 -0300 Subject: [PATCH] NBBIB-451 Add requested paragraph revision ID --- .../unblib_marc/script/import_marc.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/custom/modules/unblib_marc/script/import_marc.php b/custom/modules/unblib_marc/script/import_marc.php index 1980c8de..2d05142d 100644 --- a/custom/modules/unblib_marc/script/import_marc.php +++ b/custom/modules/unblib_marc/script/import_marc.php @@ -161,10 +161,10 @@ function migrateMarc(string $source, string $entity_type, array $map, bool $publ echo "\nSaving unpublished [$entity_type] [$title]"; //$entity->setPublished($publish); $contribs = $entity->getContributors(); - var_dump($contribs); + //var_dump($contribs); $entity->save(); $contribs = $entity->getContributors(); - var_dump($contribs); + //var_dump($contribs); } $n++; @@ -214,14 +214,15 @@ function create_author($author_name) { $author = substr($author, -1) == ',' ? substr($author, 0, -1) : $author; $author = ucwords(text_trim($author)); $author = substr($author, -2, 1) == ' ' ? "$author." : $author; - $id = createContributors([$author], 'Author')[0]->id(); + $paragraph = createContributors([$author], 'Author')[0]; + $id = $paragraph->id(); + $rid = $paragraph->getRevisionId(); $ref = [ 'target_id' => $id, + 'target_revision_id' => $rid, ]; - echo "\nContributors listing:\n"; - var_dump($ref); return $ref; } @@ -238,16 +239,17 @@ function create_contribs($contribs_blob) { $name = ucwords(text_trim($name)); $name = substr($name, -2, 1) == ' ' ? "$name." : $name; $role = ucwords(text_trim($role)); - $id = createContributors([$name], $role)[0]->id(); - + $paragraph = createContributors([$name], $role)[0]; + $id = $paragraph->id(); + $rid = $paragraph->getRevisionId(); + $refs[] = [ 'target_id' => $id, + 'target_revision_id' => $rid, ]; - } + } } - echo "\nContributors listing:\n"; - var_dump($refs); return $refs; }