Skip to content

Commit

Permalink
fix spotlight images
Browse files Browse the repository at this point in the history
  • Loading branch information
rloos289 committed Mar 12, 2024
1 parent 5df0032 commit 957a682
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public function getReferencedData(array $entities) {
'value' => $entity_data['value']['value'],
];
break;
case 'flatten_link':
$entities_data[$key] = $entity_data['value']['link']['value'];
break;

// Remove empty data.
case 'empty_data':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,18 @@ class Button extends SfgApiParagraphBase {
* {@inheritDoc}
*/
public function setCustomData($entity) {
// This is the shape wagtail expects when the button is empty.
$empty_button = [
'url' => '',
'page' => NULL,
'link_to' => '',
'link_text' => '',
];
$button_data = $this->generateLinks($entity->get('field_link')->getvalue());
$button_value = $button_data ? $button_data[0] : $empty_button;
return [
'link' => $this->generateLinks($entity->get('field_link')->getvalue()),
'alter' => 'flatten_link',
'link' => $button_value,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,23 @@ class CampaignSpotlight extends SfgApiParagraphBase {
* {@inheritDoc}
*/
public function setCustomData($entity) {
$button_data = $this->getReferencedData($entity->get('field_spotlight_button')->referencedEntities());
$empty_button = [
'url' => '',
'page' => NULL,
'link_to' => '',
'link_text' => '',
];
$button_value = $button_data ? $button_data[0] : $empty_button;

return [
// @todo , blocked by image field issue.
'image' => $this->getReferencedEntity($entity->get('field_spotlight_img')->referencedEntities(), TRUE)[0],
'title' => $entity->get('field_title')->value,
'button' => $this->collapseParagraph($this->getReferencedData($entity->get('field_spotlight_button')->referencedEntities())),
'button' => $button_value,
'banner_size' => 'full',
'description' => $entity->get('field_description')->value,
'orientation' => $this->editFieldValue($entity->get('field_is_reversed')->value, [0 => 'right', 1 => 'left']),
// @todo This doesn't have a corresponding field in drupal.
// 'banner_size' => '',
];
}

Expand Down

0 comments on commit 957a682

Please sign in to comment.