public function PropertyTypeBase::testValue in Schema.org Metatag 8.2
Provide a test input value for the property that will validate.
Tags like @type that contain values other than simple strings, for instance a list of allowed options, should extend this method and return a valid value.
Parameters
mixed $type: The default to use for the @type element, if any.
Return value
mixed Return the test value, either a string or array, depending on the property.
Overrides SchemaMetatagTestTagInterface::testValue
3 methods override PropertyTypeBase::testValue()
- Boolean::testValue in src/
Plugin/ schema_metatag/ PropertyType/ Boolean.php - Provide a test input value for the property that will validate.
- ItemListElement::testValue in src/
Plugin/ schema_metatag/ PropertyType/ ItemListElement.php - Provide a test input value for the property that will validate.
- Type::testValue in src/
Plugin/ schema_metatag/ PropertyType/ Type.php - Provide a test input value for the property that will validate.
File
- src/
Plugin/ schema_metatag/ PropertyTypeBase.php, line 317
Class
- PropertyTypeBase
- Base class for Property type plugins.
Namespace
Drupal\schema_metatag\Plugin\schema_metatagCode
public function testValue($original_type = '') {
if (empty($this
->getSubProperties())) {
return self::testDefaultValue(2, ' ');
}
else {
$items = [];
foreach ($this
->getSubProperties() as $property_name => $values) {
$plugin = $this
->getChildPropertyType($values['id']);
if ($property_name == '@type') {
$items[$property_name] = $plugin
->testValue($original_type);
}
else {
$type = !empty($values['tree_parent']) ? $values['tree_parent'] : $plugin
->getTreeParent();
$test_type = is_array($type) ? array_shift($type) : $type;
$items[$property_name] = $plugin
->testValue($test_type);
}
}
return $items;
}
}