Commit 9f2371f2 authored by alexpott's avatar alexpott

Issue #2580935 by vaplas, maijs:...

Issue #2580935 by vaplas, maijs: DisplayPluginBase::applyDisplayCachablityMetadata() method has typo in it's name
parent 4c64f7b8
...@@ -286,7 +286,7 @@ public function testBlockEmptyRendering() { ...@@ -286,7 +286,7 @@ public function testBlockEmptyRendering() {
$this->drupalGet($url); $this->drupalGet($url);
$this->assertEqual(0, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]'))); $this->assertEqual(0, count($this->xpath('//div[contains(@class, "block-views-blocktest-view-block-block-1")]')));
// Ensure that the view cachability metadata is propagated even, for an // Ensure that the view cacheability metadata is propagated even, for an
// empty block. // empty block.
$this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' , 'http_response', 'rendered'])); $this->assertCacheTags(array_merge($block->getCacheTags(), ['block_view', 'config:block_list', 'config:views.view.test_view_block' , 'http_response', 'rendered']));
$this->assertCacheContexts(['url.query_args:_wrapper_format']); $this->assertCacheContexts(['url.query_args:_wrapper_format']);
......
...@@ -435,7 +435,7 @@ public function render() { ...@@ -435,7 +435,7 @@ public function render() {
$build['#markup'] = ViewsRenderPipelineMarkup::create($build['#markup']); $build['#markup'] = ViewsRenderPipelineMarkup::create($build['#markup']);
} }
parent::applyDisplayCachablityMetadata($build); parent::applyDisplayCacheabilityMetadata($build);
return $build; return $build;
} }
......
...@@ -126,7 +126,7 @@ public function testRenderCaching() { ...@@ -126,7 +126,7 @@ public function testRenderCaching() {
$account_switcher->switchTo($this->webUser); $account_switcher->switchTo($this->webUser);
$result = $renderer->renderPlain($build); $result = $renderer->renderPlain($build);
// @todo Fix this in https://www.drupal.org/node/2551037, // @todo Fix this in https://www.drupal.org/node/2551037,
// DisplayPluginBase::applyDisplayCachablityMetadata() is not invoked when // DisplayPluginBase::applyDisplayCacheabilityMetadata() is not invoked when
// using buildBasicRenderable() and a Views access plugin returns FALSE. // using buildBasicRenderable() and a Views access plugin returns FALSE.
//$this->assertTrue(in_array('user.roles', $build['#cache']['contexts'])); //$this->assertTrue(in_array('user.roles', $build['#cache']['contexts']));
//$this->assertEqual([], $build['#cache']['tags']); //$this->assertEqual([], $build['#cache']['tags']);
......
...@@ -2114,7 +2114,7 @@ public function render() { ...@@ -2114,7 +2114,7 @@ public function render() {
'#attached' => &$this->view->element['#attached'], '#attached' => &$this->view->element['#attached'],
); );
$this->applyDisplayCachablityMetadata($this->view->element); $this->applyDisplayCacheabilityMetadata($this->view->element);
return $element; return $element;
} }
...@@ -2125,7 +2125,7 @@ public function render() { ...@@ -2125,7 +2125,7 @@ public function render() {
* @param array $element * @param array $element
* The render array with updated cacheability metadata. * The render array with updated cacheability metadata.
*/ */
protected function applyDisplayCachablityMetadata(array &$element) { protected function applyDisplayCacheabilityMetadata(array &$element) {
/** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache */ /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache */
$cache = $this->getPlugin('cache'); $cache = $this->getPlugin('cache');
...@@ -2137,6 +2137,22 @@ protected function applyDisplayCachablityMetadata(array &$element) { ...@@ -2137,6 +2137,22 @@ protected function applyDisplayCachablityMetadata(array &$element) {
->applyTo($element); ->applyTo($element);
} }
/**
* Applies the cacheability of the current display to the given render array.
*
* @param array $element
* The render array with updated cacheability metadata.
*
* @deprecated in Drupal 8.4.0, will be removed before Drupal 9.0. Use
* DisplayPluginBase::applyDisplayCacheabilityMetadata instead.
*
* @see \Drupal\views\Plugin\views\display\DisplayPluginBase::applyDisplayCacheabilityMetadata()
*/
protected function applyDisplayCachablityMetadata(array &$element) {
@trigger_error('The DisplayPluginBase::applyDisplayCachablityMetadata method is deprecated since version 8.4 and will be removed in 9.0. Use DisplayPluginBase::applyDisplayCacheabilityMetadata instead.', E_USER_DEPRECATED);
$this->applyDisplayCacheabilityMetadata($element);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -2329,7 +2345,7 @@ public function buildRenderable(array $args = [], $cache = TRUE) { ...@@ -2329,7 +2345,7 @@ public function buildRenderable(array $args = [], $cache = TRUE) {
// of cacheability metadata (e.g.: cache contexts), so they can bubble up. // of cacheability metadata (e.g.: cache contexts), so they can bubble up.
// Thus, we add the cacheability metadata first, then modify / remove the // Thus, we add the cacheability metadata first, then modify / remove the
// cache keys depending on the $cache argument. // cache keys depending on the $cache argument.
$this->applyDisplayCachablityMetadata($this->view->element); $this->applyDisplayCacheabilityMetadata($this->view->element);
if ($cache) { if ($cache) {
$this->view->element['#cache'] += ['keys' => []]; $this->view->element['#cache'] += ['keys' => []];
// Places like \Drupal\views\ViewExecutable::setCurrentPage() set up an // Places like \Drupal\views\ViewExecutable::setCurrentPage() set up an
......
...@@ -106,7 +106,7 @@ public function preview() { ...@@ -106,7 +106,7 @@ public function preview() {
public function render() { public function render() {
$build = $this->view->style_plugin->render($this->view->result); $build = $this->view->style_plugin->render($this->view->result);
$this->applyDisplayCachablityMetadata($build); $this->applyDisplayCacheabilityMetadata($build);
return $build; return $build;
} }
......
...@@ -413,7 +413,7 @@ public function testGetTasksBuildWithCacheabilityMetadata() { ...@@ -413,7 +413,7 @@ public function testGetTasksBuildWithCacheabilityMetadata() {
->method('getDefinitions') ->method('getDefinitions')
->will($this->returnValue($definitions)); ->will($this->returnValue($definitions));
// Set up some cacheablity metadata and ensure its merged together. // Set up some cacheability metadata and ensure its merged together.
$definitions['menu_local_task_test_tasks_settings']['cache_tags'] = ['tag.example1']; $definitions['menu_local_task_test_tasks_settings']['cache_tags'] = ['tag.example1'];
$definitions['menu_local_task_test_tasks_settings']['cache_contexts'] = ['context.example1']; $definitions['menu_local_task_test_tasks_settings']['cache_contexts'] = ['context.example1'];
$definitions['menu_local_task_test_tasks_edit']['cache_tags'] = ['tag.example2']; $definitions['menu_local_task_test_tasks_edit']['cache_tags'] = ['tag.example2'];
......
...@@ -671,7 +671,7 @@ public function testAddCacheableDependency(BubbleableMetadata $a, $b, Bubbleable ...@@ -671,7 +671,7 @@ public function testAddCacheableDependency(BubbleableMetadata $a, $b, Bubbleable
* *
* @return array * @return array
*/ */
public function providerTestAddCachableDependency() { public function providerTestAddCacheableDependency() {
return [ return [
// Merge in a cacheable metadata. // Merge in a cacheable metadata.
'merge-cacheable-metadata' => [ 'merge-cacheable-metadata' => [
......
...@@ -511,7 +511,7 @@ public function testRenderWithAccessControllerResolved($access) { ...@@ -511,7 +511,7 @@ public function testRenderWithAccessControllerResolved($access) {
* @covers ::render * @covers ::render
* @covers ::doRender * @covers ::doRender
*/ */
public function testRenderAccessCacheablityDependencyInheritance() { public function testRenderAccessCacheabilityDependencyInheritance() {
$build = [ $build = [
'#access' => AccessResult::allowed()->addCacheContexts(['user']), '#access' => AccessResult::allowed()->addCacheContexts(['user']),
]; ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment