Skip to content
Snippets Groups Projects
Commit 4a86d673 authored by Olga Rybak's avatar Olga Rybak Committed by Alexander Shumenko
Browse files

Issue #3041513 by Olga Rybak: Translation status isn't respected in isPublished()

parent 88a053bc
Branches
Tags 8.x-1.3
No related merge requests found
......@@ -145,7 +145,23 @@ class Widget extends ContentEntityBase implements WidgetInterface {
* {@inheritdoc}
*/
public function isPublished() {
return (bool) $this->getEntityKey('status');
// Get current language.
$lang = $this->languageManager()->getCurrentLanguage()->getId();
$is_published = (bool) $this->getEntityKey('status');
// Check if translation exists.
if (!$this->hasTranslation($lang)) {
return $is_published;
}
$translation = $this->getTranslation($lang);
if (is_null($translation) || !$translation->hasField('content_translation_status')) {
return $is_published;
}
// Get translation status.
$t_status = (bool) $translation->getTranslationStatus($lang) && $translation->get('content_translation_status')->value;
return $t_status && $is_published;
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment