Skip to content

Commit

Permalink
OEL-2258: Correct check featured item link.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tiberiu Dumitru committed Apr 25, 2023
1 parent d7bc714 commit efdbca0
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions modules/oe_whitelabel_paragraphs/oe_whitelabel_paragraphs.module
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,19 @@ function oe_whitelabel_preprocess_paragraph__oe_text_feature_media(array &$varia
'_simple',
], '', $variant);

if (empty($paragraph->get('field_oe_link')->first())) {
return;
if (!empty($paragraph->get('field_oe_link')->first())) {
/** @var \Drupal\link\Plugin\Field\FieldType\LinkItem $link_item */
$link_item = $paragraph->get('field_oe_link')->first();
$variables['link'] = [
'path' => $link_item->getUrl(),
'label' => $link_item->get('title')->getValue(),
];
}

/** @var \Drupal\link\Plugin\Field\FieldType\LinkItem $link_item */
$link_item = $paragraph->get('field_oe_link')->first();
$variables['link'] = [
'path' => $link_item->getUrl(),
'label' => $link_item->get('title')->getValue(),
];
// Caches are handled by the formatter usually. Since we are not rendering
// the original render arrays, we need to propagate our caches to the
// paragraph template.
$cacheability = CacheableMetadata::createFromRenderArray($variables);

$cacheability->applyTo($variables);

Expand All @@ -174,10 +177,6 @@ function oe_whitelabel_preprocess_paragraph__oe_text_feature_media(array &$varia
/** @var \Drupal\media\Entity\Media $media */
$media = \Drupal::service('entity.repository')->getTranslationFromContext($media, $paragraph->language()->getId());

// Caches are handled by the formatter usually. Since we are not rendering
// the original render arrays, we need to propagate our caches to the
// paragraph template.
$cacheability = CacheableMetadata::createFromRenderArray($variables);
$cacheability->addCacheableDependency($media);

// Run access checks on the media entity.
Expand Down

0 comments on commit efdbca0

Please sign in to comment.