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() ?? []);
}
$replacedData = array_replace_recursive($mergedData, $this->metadata('metadata')->all() ?? []);
$replacedData = array_merge_recursive($mergedData, $this->metadata('metadata')->all() ?? []);
return collect($replacedData);
}

View File

@ -202,28 +202,33 @@ private function parseSnak(array $data, bool $parentIncluded)
$value = $data['datavalue']['value'];
$valueType = $data['datavalue']['type'];
$dataType = $data['datatype'];
switch ($valueType) {
case 'wikibase-entityid':
$value = $this->replaceValue($value['id'], true, !$parentIncluded);
break;
case 'string':
$value = $this->replaceValue($value, true, !$parentIncluded);
break;
case 'time':
$value = $value['time'];
break;
case 'quantity':
$value = $value['amount'];
break;
case 'monolingualtext':
$value = $value['text'];
break;
case 'globecoordinate':
// Leave it as is
break;
default:
dd($data);
if ($dataType === 'external-id') {
$value = $this->replaceValue($value, true, !$parentIncluded, $data['property']);
} else {
switch ($valueType) {
case 'wikibase-entityid':
$value = $this->replaceValue($value['id'], true, !$parentIncluded);
break;
case 'string':
$value = $this->replaceValue($value, true, !$parentIncluded);
break;
case 'time':
$value = $value['time'];
break;
case 'quantity':
$value = $value['amount'];
break;
case 'monolingualtext':
$value = $value['text'];
break;
case 'globecoordinate':
// Leave it as is
break;
default:
dd($data);
}
}
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;
if (!empty($key)) {
if (!empty($key) && !empty($value)) {
$template = $this->templates[$key]['template'] ?? null;
if (!empty($template)) {
@ -306,9 +311,9 @@ private function includeProperties($includedData, $properties)
$newSubKey = $key;
if (is_string($newValues)) {
$newValues = $this->replaceValue($newValues, false, true, $propertyId);
$newValues = $this->replaceValue($newValues, false, true);
} else {
$newSubKey = $this->replaceValue($key, false, true, $propertyId);
$newSubKey = $this->replaceValue($key, false, true);
}
unset($result[$newKey][$key]);