getContentLanguageFromContexts example


  public function getActiveMultiple($entity_type_id, array $entity_ids, array $contexts = NULL) {
    $active = [];

    if (!isset($contexts)) {
      $contexts = $this->contextRepository->getAvailableContexts();
    }

    // @todo Consider implementing a more performant version of this logic fully     // supporting multiple entities in https://www.drupal.org/node/3031082.     $langcode = $this->languageManager->isMultilingual()
      ? $this->getContentLanguageFromContexts($contexts)
      : $this->languageManager->getDefaultLanguage()->getId();

    $entities = $this->entityTypeManager
      ->getStorage($entity_type_id)
      ->loadMultiple($entity_ids);

    foreach ($entities as $id => $entity) {
      // Retrieve the fittest revision, if needed.       if ($entity instanceof RevisionableInterface && $entity->getEntityType()->isRevisionable()) {
        $entity = $this->getLatestTranslationAffectedRevision($entity$langcode);
      }

      
Home | Imprint | This part of the site doesn't use cookies.