Skip to content

Commit

Permalink
Merge pull request #196 from quantcdn/feature/issue-141-unpublished-t…
Browse files Browse the repository at this point in the history
…ranslation

Updated seed logic to handle translated content.
  • Loading branch information
steveworley authored Nov 6, 2023
2 parents 6c88a23 + 9ab27f0 commit c1c4255
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/Seed.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,19 @@ public static function seedTaxonomyTerm($entity, $langcode = NULL) {
\Drupal::service('event_dispatcher')->dispatch(new QuantRedirectEvent("/taxonomy/term/{$tid}", $defaultUrl, 301), QuantRedirectEvent::UPDATE);
}

\Drupal::service('event_dispatcher')->dispatch(new QuantEvent($markup, $url, $meta, NULL, $entity, $langcode), QuantEvent::OUTPUT);
// Handle case where translation is unpublished.
$published = $entity->isPublished();
if ($entity->hasTranslation($langcode)) {
$translation = $entity->getTranslation($langcode);
$published = $translation->isPublished();
}

if ($published) {
\Drupal::service('event_dispatcher')->dispatch(new QuantEvent($markup, $url, $meta, NULL, $entity, $langcode), QuantEvent::OUTPUT);
}
else {
\Drupal::service('event_dispatcher')->dispatch(new QuantEvent('', $url, [], NULL), QuantEvent::UNPUBLISH);
}
}

/**
Expand Down Expand Up @@ -339,7 +351,19 @@ public static function seedNode(EntityInterface $entity, $langcode = NULL) {
}
}

\Drupal::service('event_dispatcher')->dispatch(new QuantEvent($markup, $url, $meta, $rid, $entity, $langcode), QuantEvent::OUTPUT);
// Handle case where translation is unpublished.
$published = $entity->isPublished();
if ($entity->hasTranslation($langcode)) {
$translation = $entity->getTranslation($langcode);
$published = $translation->isPublished();
}

if ($published) {
\Drupal::service('event_dispatcher')->dispatch(new QuantEvent($markup, $url, $meta, $rid, $entity, $langcode), QuantEvent::OUTPUT);
}
else {
\Drupal::service('event_dispatcher')->dispatch(new QuantEvent('', $url, [], NULL), QuantEvent::UNPUBLISH);
}

// Create canonical redirects from node/123 to the published revision route.
if ("/node/{$nid}" != $url && $entity->isPublished() && $entity->isDefaultRevision()) {
Expand Down

0 comments on commit c1c4255

Please sign in to comment.