1
0

Fix: Links extraction

This commit is contained in:
Richard Dern 2024-04-27 07:40:10 +02:00
parent 84da21257f
commit 77390bfb8d
2 changed files with 30 additions and 25 deletions

View File

@ -148,7 +148,7 @@ public function virtualMetadata(): Collection
$mergedData = array_merge_recursive($mergedData, $this->metadata($additionalFile)->all() ?? []); $mergedData = array_merge_recursive($mergedData, $this->metadata($additionalFile)->all() ?? []);
} }
$replacedData = array_replace_recursive($mergedData, $this->metadata('metadata')->all() ?? []); $replacedData = array_merge_recursive($mergedData, $this->metadata('metadata')->all() ?? []);
return collect($replacedData); return collect($replacedData);
} }

View File

@ -202,7 +202,11 @@ private function parseSnak(array $data, bool $parentIncluded)
$value = $data['datavalue']['value']; $value = $data['datavalue']['value'];
$valueType = $data['datavalue']['type']; $valueType = $data['datavalue']['type'];
$dataType = $data['datatype'];
if ($dataType === 'external-id') {
$value = $this->replaceValue($value, true, !$parentIncluded, $data['property']);
} else {
switch ($valueType) { switch ($valueType) {
case 'wikibase-entityid': case 'wikibase-entityid':
$value = $this->replaceValue($value['id'], true, !$parentIncluded); $value = $this->replaceValue($value['id'], true, !$parentIncluded);
@ -225,6 +229,7 @@ private function parseSnak(array $data, bool $parentIncluded)
default: default:
dd($data); dd($data);
} }
}
return $value; return $value;
} }
@ -249,7 +254,7 @@ private function replaceValue(string $value, bool $showCode = true, bool $showLa
$both = $code !== $label ? sprintf('[%s] %s', $code, $label) : $value; $both = $code !== $label ? sprintf('[%s] %s', $code, $label) : $value;
if (!empty($key)) { if (!empty($key) && !empty($value)) {
$template = $this->templates[$key]['template'] ?? null; $template = $this->templates[$key]['template'] ?? null;
if (!empty($template)) { if (!empty($template)) {
@ -306,9 +311,9 @@ private function includeProperties($includedData, $properties)
$newSubKey = $key; $newSubKey = $key;
if (is_string($newValues)) { if (is_string($newValues)) {
$newValues = $this->replaceValue($newValues, false, true, $propertyId); $newValues = $this->replaceValue($newValues, false, true);
} else { } else {
$newSubKey = $this->replaceValue($key, false, true, $propertyId); $newSubKey = $this->replaceValue($key, false, true);
} }
unset($result[$newKey][$key]); unset($result[$newKey][$key]);