Skip to content

Commit

Permalink
Fix Translation for alert banner not displaying
Browse files Browse the repository at this point in the history
  • Loading branch information
andybroomfield committed Apr 30, 2024
1 parent ee2cb8f commit 0907e92
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Entity/AlertBannerEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,19 @@ public function setOwner(UserInterface $account) {
* True if the alert banner is visible, otherwise FALSE.
*/
public function isVisible() {
$entity = $this;
$langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
if ($langcode != 'en' && $this->hasTranslation($langcode)) {
$entity = $this->getTranslation($langcode);
}

// Check if the field is present and has a value.
if (!$this->hasField('visibility') || $this->get('visibility')->isEmpty()) {
if (!$entity->hasField('visibility') || $entity->get('visibility')->isEmpty()) {
return TRUE;
}

// Visibility condition config.
$conditions_config = $this->get('visibility')->getValue()[0]['conditions'];
$conditions_config = $entity->get('visibility')->getValue()[0]['conditions'];

// Construct visibility conditions.
$conditions = [];
Expand Down

0 comments on commit 0907e92

Please sign in to comment.