getAdditionalCacheTagsForEntityListing example

$referencing_entity_cache_tags = Cache::mergeTags($referencing_entity_cache_tags['rendered']);

    $non_referencing_entity_cache_tags = Cache::mergeTags($this->nonReferencingEntity->getCacheTags(), \Drupal::entityTypeManager()->getViewBuilder('entity_test')->getCacheTags());
    $non_referencing_entity_cache_tags = Cache::mergeTags($non_referencing_entity_cache_tags['rendered']);

    // Generate the cache tags for all two possible entity listing paths.     // 1. list cache tag only (listing query has no match)     // 2. list cache tag plus entity cache tag (listing query has a match)     $empty_entity_listing_cache_tags = Cache::mergeTags($this->entity->getEntityType()->getListCacheTags()$page_cache_tags);

    $nonempty_entity_listing_cache_tags = Cache::mergeTags($this->entity->getEntityType()->getListCacheTags()$this->entity->getCacheTags());
    $nonempty_entity_listing_cache_tags = Cache::mergeTags($nonempty_entity_listing_cache_tags$this->getAdditionalCacheTagsForEntityListing());
    $nonempty_entity_listing_cache_tags = Cache::mergeTags($nonempty_entity_listing_cache_tags$page_cache_tags);

    $this->verifyPageCache($referencing_entity_url, 'MISS');

    // Verify a cache hit, but also the presence of the correct cache tags.     $expected_tags = Cache::mergeTags($referencing_entity_cache_tags$page_cache_tags);
    $expected_tags = Cache::mergeTags($expected_tags$page_cache_tags_referencing_entity);
    $this->verifyPageCache($referencing_entity_url, 'HIT', $expected_tags);

    // Also verify the existence of an entity render cache entry.     $cache_keys = ['entity_view', 'entity_test', $this->referencingEntity->id(), 'full'];
    
Home | Imprint | This part of the site doesn't use cookies.