Skip to content

Commit

Permalink
EWPP-842: Allow chart and racing services for webtols chart widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
22Alexandra committed Mar 17, 2021
1 parent 9d4c82d commit a22250e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ runner.yml
vendor
yarn.lock
docker-compose.*.yml
/.gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function validate($value, Constraint $constraint) {
}

// Add violation in case incorrect services.
if (!isset($snippet['service']) || $snippet['service'] !== $widget_types[$constraint->widgetType]['service']) {
if (!isset($snippet['service']) || !in_array($snippet['service'], $widget_types[$constraint->widgetType]['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,22 +124,22 @@ public function getWidgetTypes() {
return [
'chart' => [
'name' => $this->t('Chart'),
'service' => 'charts',
'services' => ['charts', 'chart', 'racing'],
'default_thumbnail' => 'charts-embed-no-bg.png',
],
'map' => [
'name' => $this->t('Map'),
'service' => 'map',
'services' => ['map'],
'default_thumbnail' => 'maps-embed-no-bg.png',
],
'social_feed' => [
'name' => $this->t('Social feed'),
'service' => 'smk',
'services' => ['smk'],
'default_thumbnail' => 'twitter-embed-no-bg.png',
],
'opwidget' => [
'name' => $this->t('OP Publication list'),
'service' => 'opwidget',
'services' => ['opwidget'],
'default_thumbnail' => 'generic.png',
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public function testMediaWebtoolsSource(string $widget_type, string $widget_name
public function providerTestMediaWebtoolsSource(): array {
return [
['chart', 'Chart', 'charts', '/charts-embed-no-bg.png'],
['chart', 'Chart', 'chart', '/charts-embed-no-bg.png'],
['chart', 'Chart', 'racing', '/charts-embed-no-bg.png'],
['map', 'Map', 'map', '/maps-embed-no-bg.png'],
['social_feed', 'Social feed', 'smk', '/twitter-embed-no-bg.png'],
['opwidget', 'OP Publication list', 'opwidget', '/generic.png'],
Expand Down

0 comments on commit a22250e

Please sign in to comment.