Skip to content
Snippets Groups Projects

#3498269: PHP warnings thrown for optional image or date-time SDC props without examples

Merged #3498269: PHP warnings thrown for optional image or date-time SDC props without examples
All threads resolved!
All threads resolved!
1 file
+ 9
3
Compare changes
  • Side-by-side
  • Inline
@@ -379,9 +379,15 @@ final class SingleDirectoryComponent extends ComponentSourceBase implements Comp
@@ -379,9 +379,15 @@ final class SingleDirectoryComponent extends ComponentSourceBase implements Comp
// @see \Drupal\experience_builder\Entity\Component::getDefaultsForComponentPlugin
// @see \Drupal\experience_builder\Entity\Component::getDefaultsForComponentPlugin
$is_datetime = isset($prop_info['format']) && $prop_info['format'] === 'date-time';
$is_datetime = isset($prop_info['format']) && $prop_info['format'] === 'date-time';
// @todo DateTimeItem stores information in a format that clashes with JSON schema's, and it has no automatic conversion. Figure out a better solution for both this and \Drupal\experience_builder\PropExpressions\StructuredData\Evaluator::evaluate().
// @todo DateTimeItem stores information in a format that clashes with JSON schema's, and it has no automatic conversion. Figure out a better solution for both this and \Drupal\experience_builder\PropExpressions\StructuredData\Evaluator::evaluate().
$default_value = ($is_image || $is_datetime)
$default_value = NULL;
? $prop_info['examples'][0]
if (($is_image || $is_datetime)) {
: $component->getDefaultStaticPropSource($component_prop->propName)->evaluate(NULL);
if (isset($prop_info['examples']) && is_array($prop_info['examples']) && !empty($prop_info['examples'])) {
 
$default_value = $prop_info['examples'][0];
 
}
 
}
 
else {
 
$default_value = $component->getDefaultStaticPropSource($component_prop->propName)->evaluate(NULL);
 
}
if ($default_value !== NULL) {
if ($default_value !== NULL) {
$keyed_choices[$component_prop->propName]['default_values'] = $default_value;
$keyed_choices[$component_prop->propName]['default_values'] = $default_value;
$default_props_for_default_markup[$component_prop->propName] = $default_value;
$default_props_for_default_markup[$component_prop->propName] = $default_value;
Loading