Skip to content

Commit 09ea2d3

Browse files
committed
Move entity translation logic to Seed.
1 parent 4c60fb7 commit 09ea2d3

3 files changed

Lines changed: 11 additions & 8 deletions

File tree

modules/quant_cron/quant_cron.module

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ function quant_cron_cron() {
7070
if (!empty($filter) && !in_array($langcode, $filter)) {
7171
continue;
7272
}
73-
$translated_entity = $entity->getTranslation($langcode);
74-
Seed::seedNode($translated_entity, $langcode);
73+
Seed::seedNode($entity, $langcode);
7574

7675
\Drupal::logger('quant_cron')->notice("quant_cron sending node: nid: @nid, langcode: @lang",
7776
[
@@ -93,8 +92,7 @@ function quant_cron_cron() {
9392
$term = Term::load($tid);
9493

9594
foreach ($term->getTranslationLanguages() as $langcode => $language) {
96-
$translated_term = $term->getTranslation($langcode);
97-
Seed::seedTaxonomyTerm($translated_term, $langcode);
95+
Seed::seedTaxonomyTerm($term, $langcode);
9896

9997
\Drupal::logger('quant_cron')->notice("quant_cron sending term: tid: @tid, langcode: @lang",
10098
[

src/Plugin/QueueItem/NodeItem.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,15 @@ public function send() {
7676
continue;
7777
}
7878

79-
\Drupal::logger('quant_seed')->notice(
79+
\Drupal::logger('quant')->notice(
8080
'Processing language @langcode for node @id',
8181
[
8282
'@langcode' => $langcode,
8383
'@id' => $this->id,
8484
]
8585
);
8686

87-
// getTranslation provides more accurate published status.
88-
$translated_entity = $entity->getTranslation($langcode);
89-
Seed::seedNode($translated_entity, $langcode);
87+
Seed::seedNode($entity, $langcode);
9088
}
9189
}
9290

src/Seed.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ public static function unpublishRedirect($redirect) {
212212
* Seeds taxonomy term.
213213
*/
214214
public static function seedTaxonomyTerm($entity, $langcode = NULL) {
215+
216+
// Use the translation to ensure correct metadata such as published state.
217+
$entity = $entity->getTranslation($langcode);
218+
215219
$tid = $entity->get('tid')->value;
216220

217221
$url = Utility::getCanonicalUrl('taxonomy_term', $tid, $langcode);
@@ -264,6 +268,9 @@ public static function seedTaxonomyTerm($entity, $langcode = NULL) {
264268
*/
265269
public static function seedNode(EntityInterface $entity, $langcode = NULL) {
266270

271+
// Use the translation to ensure correct metadata such as published state.
272+
$entity = $entity->getTranslation($langcode);
273+
267274
$nid = $entity->get('nid')->value;
268275
$rid = $entity->get('vid')->value;
269276

0 commit comments

Comments
 (0)