本文整理汇总了PHP中Drupal\views\Views::getview方法的典型用法代码示例。如果您正苦于以下问题:PHP Views::getview方法的具体用法?PHP Views::getview怎么用?PHP Views::getview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\views\Views
的用法示例。
在下文中一共展示了Views::getview方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertCacheTagsForEntityBasedView
/**
* Tests cache tags on output & result cache items for an entity-based view.
*/
protected function assertCacheTagsForEntityBasedView($do_assert_views_caches)
{
$this->pass('Checking cache tags for entity-based view.');
$view = Views::getview('entity_test_row');
// Empty result (no entities yet).
$base_tags = $base_render_tags = ['config:views.view.entity_test_row', 'entity_test_list'];
$this->assertViewsCacheTags($view, $base_tags, $do_assert_views_caches, $base_tags);
$this->assertViewsCacheTagsFromStaticRenderArray($view, $base_tags, $do_assert_views_caches);
// Non-empty result (1 entity).
$entities[] = $entity = EntityTest::create();
$entity->save();
$result_tags_with_entity = Cache::mergeTags($base_tags, $entities[0]->getCacheTags());
$render_tags_with_entity = Cache::mergeTags($base_render_tags, $entities[0]->getCacheTags());
$render_tags_with_entity = Cache::mergeTags($render_tags_with_entity, ['entity_test_view']);
$this->assertViewsCacheTags($view, $result_tags_with_entity, $do_assert_views_caches, $render_tags_with_entity);
$this->assertViewsCacheTagsFromStaticRenderArray($view, $render_tags_with_entity, $do_assert_views_caches);
// Paged result (more entities than the items-per-page limit).
for ($i = 0; $i < 5; $i++) {
$entities[] = $entity = EntityTest::create();
$entity->save();
}
$new_entities_cache_tags = Cache::mergeTags($entities[1]->getCacheTags(), $entities[2]->getCacheTags());
$new_entities_cache_tags = Cache::mergeTags($new_entities_cache_tags, $entities[3]->getCacheTags());
$new_entities_cache_tags = Cache::mergeTags($new_entities_cache_tags, $entities[4]->getCacheTags());
$new_entities_cache_tags = Cache::mergeTags($new_entities_cache_tags, $entities[5]->getCacheTags());
$result_tags_page_1 = Cache::mergeTags($base_tags, $new_entities_cache_tags);
$render_tags_page_1 = Cache::mergeTags($base_render_tags, $new_entities_cache_tags);
$render_tags_page_1 = Cache::mergeTags($render_tags_page_1, ['entity_test_view']);
$this->assertViewsCacheTags($view, $result_tags_page_1, $do_assert_views_caches, $render_tags_page_1);
$this->assertViewsCacheTagsFromStaticRenderArray($view, $render_tags_page_1, $do_assert_views_caches);
}