getActiveMultiple example


      }
    }

    return $translation;
  }

  /** * {@inheritdoc} */
  public function getActive($entity_type_id$entity_id, array $contexts = NULL) {
    return current($this->getActiveMultiple($entity_type_id[$entity_id]$contexts)) ?: NULL;
  }

  /** * {@inheritdoc} */
  public function getActiveMultiple($entity_type_id, array $entity_ids, array $contexts = NULL) {
    $active = [];

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

    
$this->assertSame($it_revision2->getLoadedRevisionId()$active->getLoadedRevisionId());
    $this->assertSame($it_revision2->getUntranslated()->language()->getId()$active->language()->getId());

    $active = $this->entityRepository->getActive($entity_type_id$entity->id()$it_contexts);
    $this->assertSame($it_revision2->getLoadedRevisionId()$active->getLoadedRevisionId());
    $this->assertSame($it_revision2->language()->getId()$active->language()->getId());

    /** @var \Drupal\entity_test\Entity\EntityTestMulRev $entity2 */
    $entity2 = $storage->create($values);
    $storage->save($entity2);
    /** @var \Drupal\Core\Entity\ContentEntityInterface[] $active */
    $active = $this->entityRepository->getActiveMultiple($entity_type_id[$entity->id()$entity2->id()]$it_contexts);
    $this->assertSame($it_revision2->getLoadedRevisionId()$active[$entity->id()]->getLoadedRevisionId());
    $this->assertSame($it_revision2->language()->getId()$active[$entity->id()]->language()->getId());
    $this->assertSame($entity2->getLoadedRevisionId()$active[$entity2->id()]->getLoadedRevisionId());
    $this->assertSame($entity2->language()->getId()$active[$entity2->id()]->language()->getId());

    $this->doTestLanguageFallback('getActive');
  }

  /** * Tests retrieving canonical variants. * * @covers ::getCanonical * @covers ::getCanonicalMultiple */
Home | Imprint | This part of the site doesn't use cookies.