Skip to content
Snippets Groups Projects

Resolve #3458764 "Improve additional type"

3 files
+ 30
9
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -56,7 +56,7 @@ class SchemaDotOrgAdditionalTypeManager implements SchemaDotOrgAdditionalTypeMan
return;
}
$allowed_values = $this->getAllowedValues($schema_type);
$allowed_values = $this->getAllowedValues($entity_type_id, $bundle, $schema_type);
if (empty($allowed_values)) {
return;
}
@@ -112,7 +112,11 @@ class SchemaDotOrgAdditionalTypeManager implements SchemaDotOrgAdditionalTypeMan
}
// Make sure the Schema.org type has subtypes or default allowed values.
$allowed_values = $this->getAllowedValues($schema_type);
$allowed_values = $this->getAllowedValues(
$mapping->getEntityTypeId(),
$mapping->getTargetBundle(),
$mapping->getSchemaType()
);
if (empty($allowed_values)) {
return;
}
@@ -225,19 +229,28 @@ AdditionalType: Additional Type
}
/**
* Retrieves the allowed values for a Schema.org type.
* Get allowed values for a Schema.org type.
*
* @param string $entity_type_id
* The entity type ID.
* @param string|null $bundle
* The entity bundle.
* @param string $schema_type
* The schema type.
* The Schema.org type.
*
* @return array
* An array of allowed values for the Schema.org type.
* An array of allowed values.
*/
protected function getAllowedValues(string $schema_type): array {
protected function getAllowedValues(string $entity_type_id, ?string $bundle, string $schema_type): array {
$allowed_values = $this->configFactory
->get('schemadotorg_additional_type.settings')
->get('default_allowed_values');
return $allowed_values[$schema_type]
$parts = [
'entity_type_id' => $entity_type_id,
'bundle' => $bundle,
'schema_type' => $schema_type,
];
return $this->schemaTypeManager->getSetting($allowed_values, $parts)
?? $this->schemaTypeManager->getAllTypeChildrenAsOptions($schema_type);
}
Loading