Skip to content

Commit

Permalink
Merge pull request #152 from openeuropa/EWPP-842
Browse files Browse the repository at this point in the history
EWPP-842: Allow chart and racing services for webtols chart widget.
  • Loading branch information
upchuk authored Apr 12, 2021
2 parents 9d4c82d + 2fa7f59 commit ccf79e8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 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,8 @@ public function validate($value, Constraint $constraint) {
}

// Add violation in case incorrect services.
if (!isset($snippet['service']) || $snippet['service'] !== $widget_types[$constraint->widgetType]['service']) {
$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
14 changes: 11 additions & 3 deletions modules/oe_webtools_media/src/Plugin/media/Source/Webtools.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,30 @@ 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'),
'service' => 'map',
// @deprecated Use services key instead.
'service' => '',
'services' => ['map'],
'default_thumbnail' => 'maps-embed-no-bg.png',
],
'social_feed' => [
'name' => $this->t('Social feed'),
'service' => 'smk',
// @deprecated Use services key instead.
'service' => '',
'services' => ['smk'],
'default_thumbnail' => 'twitter-embed-no-bg.png',
],
'opwidget' => [
'name' => $this->t('OP Publication list'),
'service' => 'opwidget',
// @deprecated Use services key instead.
'service' => '',
'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 ccf79e8

Please sign in to comment.