From b99d7ae9711c5dd2087fe680f9976cb58b1e69d4 Mon Sep 17 00:00:00 2001 From: Dendy Faist Date: Thu, 6 Feb 2025 16:15:25 +0900 Subject: [PATCH] fix: Set fields to the values, ignore anki sent order PHP automatically maintains the order properly. Maybe just to make sure it would be nice to somehow check the order but for now I'm leaving it like this --- src/Entity/Note.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Entity/Note.php b/src/Entity/Note.php index c9f9cf5..9b7c39f 100644 --- a/src/Entity/Note.php +++ b/src/Entity/Note.php @@ -51,23 +51,22 @@ class Note 'mod' => $note->mod, 'profile' => $note->profile, 'tags' => $note->tags, - 'fields' => $note->fields, 'modelName' => $note->model, 'cards' => $note->cardIds, ] = $noteInfo; - $fields = array_map(fn($x) => $x['value'], $noteInfo['fields']); + $note->fields = array_map(fn($x) => $x['value'], $noteInfo['fields']); // Set VocabKanji field - //$vocabKanji = explode('|', $fields['VocabKanji']); - $note->terms = self::parseVocabDef($fields['VocabDef']); + //$vocabKanji = explode('|', $note->fields['VocabKanji']); + $note->terms = self::parseVocabDef($note->fields['VocabDef']); // If not defined, find them from the highlighted parts in the sentence if (empty($note->terms)) { // 1. Get all spans in the text preg_match_all( self::HIGHLIGHT_PATTERN, - $fields['SentKanji'], + $note->fields['SentKanji'], $matches, PREG_SET_ORDER, ); @@ -86,7 +85,7 @@ class Note // Set to null whatever is null $readings = array_map( fn($x) => in_array($x, ['_', '_', '']) ? null : $x, - explode('|', $fields['VocabFurigana']), + explode('|', $note->fields['VocabFurigana']), ); // Set readings from furigana field