You are here

protected function ProductBundleItem::ensureTranslations in Commerce Product Bundle 8

Ensures that the provided entities are in the current entity's language.

Parameters

\Drupal\Core\Entity\ContentEntityInterface[] $entities: The entities to process.

Return value

\Drupal\Core\Entity\ContentEntityInterface[] The processed entities.

1 call to ProductBundleItem::ensureTranslations()
ProductBundleItem::getVariations in src/Entity/ProductBundleItem.php
Gets the product variations limited by the bundle item or enabled on the product.

File

src/Entity/ProductBundleItem.php, line 704

Class

ProductBundleItem
Defines the product bundle item entity.

Namespace

Drupal\commerce_product_bundle\Entity

Code

protected function ensureTranslations(array $entities) {
  $langcode = $this
    ->language()
    ->getId();
  foreach ($entities as $index => $entity) {

    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    if ($entity
      ->hasTranslation($langcode)) {
      $entities[$index] = $entity
        ->getTranslation($langcode);
    }
  }
  return $entities;
}