Skip to content

Commit

Permalink
EWPP-842: Ensure backward compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
22Alexandra committed Apr 12, 2021
1 parent a22250e commit 2fa7f59
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function validate($value, Constraint $constraint) {
}

// Add violation in case incorrect services.
if (!isset($snippet['service']) || !in_array($snippet['service'], $widget_types[$constraint->widgetType]['services'])) {
$services = $widget_types[$constraint->widgetType]['services'] ?? [$widget_types[$constraint->widgetType]['service']];
if (!in_array($snippet['service'], $services)) {
$this->context->addViolation($constraint->message, ['%widget_type_name' => $widget_types[$constraint->widgetType]['name']]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,29 @@ public function getWidgetTypes() {
return [
'chart' => [
'name' => $this->t('Chart'),
// @deprecated Use services key instead.
'service' => 'charts',
'services' => ['charts', 'chart', 'racing'],
'default_thumbnail' => 'charts-embed-no-bg.png',
],
'map' => [
'name' => $this->t('Map'),
// @deprecated Use services key instead.
'service' => '',
'services' => ['map'],
'default_thumbnail' => 'maps-embed-no-bg.png',
],
'social_feed' => [
'name' => $this->t('Social feed'),
// @deprecated Use services key instead.
'service' => '',
'services' => ['smk'],
'default_thumbnail' => 'twitter-embed-no-bg.png',
],
'opwidget' => [
'name' => $this->t('OP Publication list'),
// @deprecated Use services key instead.
'service' => '',
'services' => ['opwidget'],
'default_thumbnail' => 'generic.png',
],
Expand Down

0 comments on commit 2fa7f59

Please sign in to comment.