filtered articles index if translated or not in current language

This commit is contained in:
2018-10-23 17:05:58 +02:00
parent c691e6c26e
commit 6bf38a0301
@@ -262,6 +262,8 @@ class CorpusController extends ControllerBase {
$nids = $query->execute();
$nodes = entity_load_multiple('node', $nids);
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$this->articles_nodes = [];
$this->articles_nids = [];
foreach ($nodes as $node) {
@@ -269,6 +271,10 @@ class CorpusController extends ControllerBase {
$sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
if($sid != 'corpus_documents_publie') continue;
// TODO: check if article is translated
if (!$node->hasTranslation($current_langcode)
|| $node->getTranslation($current_langcode)->body->isEmpty()) continue;
$this->articles_nodes[] = $node;
// record an array of nids for corpus map filtering
$this->articles_nids[] = $node->get('nid')->getString();