fixed the default base page lang code bug
This commit is contained in:
@@ -62,7 +62,7 @@ class Base extends ControllerBase {
|
||||
$entity_storage = \Drupal::entityTypeManager()->getStorage('node');
|
||||
$this->query = $entity_storage->getQuery()
|
||||
->condition('type', 'materiau')
|
||||
// ->condition('status', '1')
|
||||
->condition('status', '1')
|
||||
->range($this->offset, $this->limit)
|
||||
->accessCheck(TRUE)
|
||||
->sort('changed', 'DESC');
|
||||
@@ -72,7 +72,7 @@ class Base extends ControllerBase {
|
||||
$this->count_query = $entity_storage->getQuery()
|
||||
->condition('type', 'materiau')
|
||||
->accessCheck(TRUE)
|
||||
// ->condition('status', '1')
|
||||
->condition('status', '1')
|
||||
->count();
|
||||
$this->count = $this->count_query->execute();
|
||||
}
|
||||
@@ -143,9 +143,21 @@ class Base extends ControllerBase {
|
||||
$this->defaultQuery();
|
||||
// $uuids = [];
|
||||
$nids = [];
|
||||
// Using entityTypeManager
|
||||
// Get a node storage object.
|
||||
$node_storage = \Drupal::entityTypeManager()->getStorage('node');
|
||||
|
||||
foreach ($this->results as $result) {
|
||||
// $uuids[] = $result->getField('uuid')->getValues()[0];
|
||||
$nids[] = $result;
|
||||
$lang = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
// Load a single node.
|
||||
$node = $node_storage->load($result);
|
||||
// check if has translation
|
||||
|
||||
if ($node->hasTranslation($lang)) {
|
||||
// $uuids[] = $result->getField('uuid')->getValues()[0];
|
||||
$nids[] = $result;
|
||||
}
|
||||
|
||||
}
|
||||
// $resp['uuids'] = $uuids;
|
||||
$resp['nids'] = $nids;
|
||||
|
Reference in New Issue
Block a user