From 5cefa04bc4c54c0c5990a03b94c4e11392d9f852 Mon Sep 17 00:00:00 2001 From: Touhidur Rahman Date: Tue, 20 Aug 2024 09:24:48 +0600 Subject: [PATCH] pkp/pkp-lib#10292 proper model import for native xml --- .../filter/NativeXmlPKPPublicationFilter.php | 14 +++++++++----- .../filter/PKPPublicationNativeXmlFilter.php | 12 ++++++++---- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/plugins/importexport/native/filter/NativeXmlPKPPublicationFilter.php b/plugins/importexport/native/filter/NativeXmlPKPPublicationFilter.php index ec753b9a9af..eb7d47f506f 100644 --- a/plugins/importexport/native/filter/NativeXmlPKPPublicationFilter.php +++ b/plugins/importexport/native/filter/NativeXmlPKPPublicationFilter.php @@ -24,6 +24,10 @@ use PKP\filter\Filter; use PKP\filter\FilterGroup; use PKP\plugins\PluginRegistry; +use PKP\submission\SubmissionKeywordVocab; +use PKP\submission\SubmissionAgencyVocab; +use PKP\submission\SubmissionDisciplineVocab; +use PKP\submission\SubmissionSubjectVocab; class NativeXmlPKPPublicationFilter extends NativeImportFilter { @@ -138,7 +142,7 @@ public function handleChildElement($n, $publication) if (in_array($n->tagName, $setterMappings)) { $publication->setData($n->tagName, $value, $locale); } elseif (isset($controlledVocabulariesMappings[$n->tagName])) { - $controlledVocabulariesModel = $submissionKeywordModel = $controlledVocabulariesMappings[$n->tagName][0]; + $controlledVocabulariesModel = $controlledVocabulariesMappings[$n->tagName][0]; $insertFunction = $controlledVocabulariesMappings[$n->tagName][1]; $controlledVocabulary = []; @@ -315,10 +319,10 @@ public function _getLocalizedPublicationFields() public function _getControlledVocabulariesMappings() { return [ - 'keywords' => ['SubmissionKeywordVocab', 'insertKeywords'], - 'agencies' => ['SubmissionAgencyVocab', 'insertAgencies'], - 'disciplines' => ['SubmissionDisciplineVocab', 'insertDisciplines'], - 'subjects' => ['SubmissionSubjectVocab', 'insertSubjects'], + 'keywords' => [SubmissionKeywordVocab::class, 'insertKeywords'], + 'agencies' => [SubmissionAgencyVocab::class, 'insertAgencies'], + 'disciplines' => [SubmissionDisciplineVocab::class, 'insertDisciplines'], + 'subjects' => [SubmissionSubjectVocab::class, 'insertSubjects'], ]; } diff --git a/plugins/importexport/native/filter/PKPPublicationNativeXmlFilter.php b/plugins/importexport/native/filter/PKPPublicationNativeXmlFilter.php index 9e5a37106cb..c8937b63140 100644 --- a/plugins/importexport/native/filter/PKPPublicationNativeXmlFilter.php +++ b/plugins/importexport/native/filter/PKPPublicationNativeXmlFilter.php @@ -28,6 +28,10 @@ use PKP\submission\PKPSubmission; use PKP\submission\Representation; use PKP\submission\RepresentationDAOInterface; +use PKP\submission\SubmissionKeywordVocab; +use PKP\submission\SubmissionAgencyVocab; +use PKP\submission\SubmissionDisciplineVocab; +use PKP\submission\SubmissionSubjectVocab; class PKPPublicationNativeXmlFilter extends NativeExportFilter { @@ -304,10 +308,10 @@ public function addRepresentations($doc, $entityNode, $entity) public function _getControlledVocabulariesMappings() { return [ - 'keywords' => ['SubmissionKeywordVocab', 'getKeywords', 'keyword'], - 'agencies' => ['SubmissionAgencyVocab', 'getAgencies', 'agency'], - 'disciplines' => ['SubmissionDisciplineVocab', 'getDisciplines', 'discipline'], - 'subjects' => ['SubmissionSubjectVocab', 'getSubjects', 'subject'], + 'keywords' => [SubmissionKeywordVocab::class, 'getKeywords', 'keyword'], + 'agencies' => [SubmissionAgencyVocab::class, 'getAgencies', 'agency'], + 'disciplines' => [SubmissionDisciplineVocab::class, 'getDisciplines', 'discipline'], + 'subjects' => [SubmissionSubjectVocab::class, 'getSubjects', 'subject'], ]; }