diff --git a/lib/ContentHelpers.php b/lib/ContentHelpers.php index fa317e74..9f43b3e6 100644 --- a/lib/ContentHelpers.php +++ b/lib/ContentHelpers.php @@ -29,7 +29,7 @@ private static function buildTrailImage($imageField) ]) : null; } - public static function getCommonFields(Entry $entry, $status, $locale, $includeHeroes = true) + public static function getCommonFields(Entry $entry, $status, $locale, $includeHeroes = true, $includeExpiredForTranslations = false) { $fields = [ 'id' => $entry->id, @@ -39,7 +39,7 @@ public static function getCommonFields(Entry $entry, $status, $locale, $includeH 'postDate' => $entry->postDate, 'dateCreated' => $entry->dateCreated, 'dateUpdated' => $entry->dateUpdated, - 'availableLanguages' => EntryHelpers::getAvailableLanguages($entry->id, $locale), + 'availableLanguages' => EntryHelpers::getAvailableLanguages($entry->id, $locale, $includeExpiredForTranslations), 'openGraph' => self::extractSocialMetaTags($entry), // @TODO: Is url used anywhere? 'url' => $entry->url, diff --git a/lib/EntryHelpers.php b/lib/EntryHelpers.php index 4ba615be..9f1a1f76 100644 --- a/lib/EntryHelpers.php +++ b/lib/EntryHelpers.php @@ -12,13 +12,19 @@ public static function translate($locale, $message, $variables = array()) return \Craft::t('site', $message, $variables, $locale); } - public static function getAvailableLanguages($entryId, $currentLanguage) + public static function getAvailableLanguages($entryId, $currentLanguage, $includeExpiredForTranslations = false) { + $statuses = ['live']; $alternateLanguage = $currentLanguage === 'en' ? 'cy' : 'en'; + if ($includeExpiredForTranslations) { + $statuses[] = 'expired'; + } + $altEntry = Entry::find() ->id($entryId) ->site($alternateLanguage) + ->status($statuses) ->one(); $availableLanguages = [$currentLanguage]; diff --git a/lib/FundingProgrammes.php b/lib/FundingProgrammes.php index 58886d5f..3362b43a 100644 --- a/lib/FundingProgrammes.php +++ b/lib/FundingProgrammes.php @@ -30,7 +30,7 @@ private static function buildTrailImage($imageField) public function transform(Entry $entry) { list('entry' => $entry, 'status' => $status) = EntryHelpers::getDraftOrVersionOfEntry($entry); - $commonFields = ContentHelpers::getCommonFields($entry, $status, $this->locale, $includeHeroes = $this->isSingle); + $commonFields = ContentHelpers::getCommonFields($entry, $status, $this->locale, $includeHeroes = $this->isSingle, $includeExpiredForTranslations = true); if ($entry->type->handle === 'contentPage') { return ContentHelpers::getFlexibleContentPage($entry, $this->locale);