Skip to content

Commit

Permalink
Merge pull request #795 from UN-OCHA/berliner/HPC-9191
Browse files Browse the repository at this point in the history
HPC-9191: Fix regression in article search
  • Loading branch information
berliner authored Nov 10, 2023
2 parents 51342d8 + 42856c6 commit 631b2c2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ public function nodeEditFormAlter(array &$form, FormStateInterface $form_state)
$form['remote_content_info']['status'] = [
'#type' => 'item',
'#title' => $this->t('Up to date'),
'#markup' => '<p>' . $this->t('This @label page is up to date with its source content on the remote system.', $t_args) . '</p>',
'#markup' => '<p>' . $this->t('This @label is up to date with its source content on the remote system.', $t_args) . '</p>',
'#weight' => 1,
];

Expand Down
20 changes: 18 additions & 2 deletions html/modules/custom/ghi_hero_image/src/HeroImageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ public function __construct(EndpointQueryManager $endpoint_query_manager, Image
$this->fileSystem = $file_system;
}

/**
* Get the default item source.
*
* @param \Drupal\Core\Field\FieldItemListInterface $items
* The field values to be rendered.
*
* @return string
* The item source as a string.
*/
public function getDefaultItemSource(FieldItemListInterface $items) {
if ($this->getPlanWebContentAttachments($items)) {
return 'hpc_webcontent_file_attachment';
}
return 'none';
}

/**
* Get properties for a hero image.
*
Expand All @@ -65,8 +81,8 @@ public function getImageProperties(FieldItemListInterface $items, FormatterInter

$item = !$items->isEmpty() ? (object) $items->get(0)->getValue() ?? NULL : NULL;
$item_source = $item ? $item->source : NULL;
if (!$item_source && $attachments = $this->getPlanWebContentAttachments($items)) {
$item_source = 'hpc_webcontent_file_attachment';
if (!$item_source) {
$item_source = $this->getDefaultItemSource($items);
}

$item_settings = $item && property_exists($item, 'settings') && is_array($item->settings) ? ($item->settings[$item_source] ?? []) : [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
$entity = $items->getEntity();
$item = !$items->isEmpty() ? (object) $items->get(0)->getValue() ?? NULL : NULL;
$item_source = $item ? $item->source : NULL;
if (!$item_source && $this->getPlanWebContentAttachments($items)) {
$item_source = 'hpc_webcontent_file_attachment';
if (!$item_source) {
$item_source = $this->heroImageManager->getDefaultItemSource($items);
}

if ($item_source == 'inherit') {
Expand Down

0 comments on commit 631b2c2

Please sign in to comment.