$render_cache = \Drupal::
service('render_cache'
);
// Enable render caching for the views.
/** @var \Drupal\views\ViewEntityInterface $storage */
$storage = View::
load('test_serializer_display_entity'
);
$options = &
$storage->
getDisplay('default'
);
$options['display_options'
]['cache'
] =
[ 'type' => 'tag',
];
$storage->
save();
$original = DisplayPluginBase::
buildBasicRenderable('test_serializer_display_entity', 'rest_export_1'
);
// Ensure that there is no corresponding render cache item yet.
$original['#cache'
] +=
['contexts' =>
[]];
$original['#cache'
]['contexts'
] = Cache::
mergeContexts($original['#cache'
]['contexts'
],
$this->container->
getParameter('renderer.config'
)['required_cache_contexts'
]);
$cache_tags =
[ 'config:views.view.test_serializer_display_entity',
'entity_test:1',
'entity_test:10',
'entity_test:2',
'entity_test:3',