core/lib/Drupal/Core/Cache/CacheableResponseInterface.php | 2 +- core/lib/Drupal/Core/Cache/CacheableResponseTrait.php | 2 +- core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php | 6 +++--- core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php | 2 +- .../Core/EventSubscriber/AnonymousUserResponseSubscriber.php | 2 +- .../Core/EventSubscriber/ClientErrorResponseSubscriber.php | 2 +- .../Core/EventSubscriber/RouteAccessResponseSubscriber.php | 2 +- core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php | 4 ++-- core/lib/Drupal/Core/Render/Renderer.php | 2 +- core/lib/Drupal/Core/Render/RendererInterface.php | 2 +- core/modules/book/src/BookManager.php | 2 +- core/modules/comment/src/CommentForm.php | 4 ++-- core/modules/contact/src/Controller/ContactController.php | 2 +- core/modules/forum/src/Controller/ForumController.php | 2 +- core/modules/rest/src/Plugin/rest/resource/EntityResource.php | 2 +- core/modules/rest/src/RequestHandler.php | 2 +- core/modules/rest/src/ResourceResponse.php | 1 - .../system_test/src/Controller/SystemTestController.php | 2 +- core/modules/user/src/Form/UserLoginForm.php | 2 +- core/tests/Drupal/Tests/Core/Render/RendererTest.php | 10 +++++----- 20 files changed, 27 insertions(+), 28 deletions(-) diff --git a/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php b/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php index c427103..3b28794 100644 --- a/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php +++ b/core/lib/Drupal/Core/Cache/CacheableResponseInterface.php @@ -24,7 +24,7 @@ * @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency * The dependency. */ - public function addCacheabilityDependency($dependency); + public function addCacheableDependency($dependency); /** * Returns the cacheability metadata for this response. diff --git a/core/lib/Drupal/Core/Cache/CacheableResponseTrait.php b/core/lib/Drupal/Core/Cache/CacheableResponseTrait.php index 5e59a4a..505d7c5 100644 --- a/core/lib/Drupal/Core/Cache/CacheableResponseTrait.php +++ b/core/lib/Drupal/Core/Cache/CacheableResponseTrait.php @@ -19,7 +19,7 @@ /** * {@inheritdoc} */ - public function addCacheabilityDependency($dependency) { + public function addCacheableDependency($dependency) { // A trait doesn't have a constructor, so initialize the cacheability // metadata if that hasn't happened yet. if (!isset($this->cacheabilityMetadata)) { diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php index 1ad81e1..ae4b46d 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php @@ -169,13 +169,13 @@ public function buildForm(FieldableEntityInterface $entity, array &$form, FormSt // Associate the cache tags for the field definition & field storage // definition. $field_definition = $this->getFieldDefinition($name); - $this->renderer->addCacheabilityDependency($form[$name], $field_definition); - $this->renderer->addCacheabilityDependency($form[$name], $field_definition->getFieldStorageDefinition()); + $this->renderer->addCacheableDependency($form[$name], $field_definition); + $this->renderer->addCacheableDependency($form[$name], $field_definition->getFieldStorageDefinition()); } } // Associate the cache tags for the form display. - $this->renderer->addCacheabilityDependency($form, $this); + $this->renderer->addCacheableDependency($form, $this); // Add a process callback so we can assign weights and hide extra fields. $form['#process'][] = array($this, 'processForm'); diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php index 70c5b79..5b28f76 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php @@ -242,7 +242,7 @@ public function buildMultiple(array $entities) { $field_access = $items->access('view', NULL, TRUE); $build_list[$id][$name] = $field_access->isAllowed() ? $formatter->view($items) : []; // Apply the field access cacheability metadata to the render array. - $this->renderer->addCacheabilityDependency($build_list[$id][$name], $field_access); + $this->renderer->addCacheableDependency($build_list[$id][$name], $field_access); } } } diff --git a/core/lib/Drupal/Core/EventSubscriber/AnonymousUserResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AnonymousUserResponseSubscriber.php index 496d5c0..569a473 100644 --- a/core/lib/Drupal/Core/EventSubscriber/AnonymousUserResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/AnonymousUserResponseSubscriber.php @@ -68,7 +68,7 @@ public function onRespond(FilterResponseEvent $event) { if (in_array('user.permissions', $response->getCacheability()->getCacheContexts())) { $per_permissions_response_for_anon = new CacheableMetadata(); $per_permissions_response_for_anon->setCacheTags(['config:user.role.anonymous']); - $response->addCacheabilityDependency($per_permissions_response_for_anon); + $response->addCacheableDependency($per_permissions_response_for_anon); } } diff --git a/core/lib/Drupal/Core/EventSubscriber/ClientErrorResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/ClientErrorResponseSubscriber.php index 9bf3ff0..5b4f0bd 100644 --- a/core/lib/Drupal/Core/EventSubscriber/ClientErrorResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/ClientErrorResponseSubscriber.php @@ -37,7 +37,7 @@ public function onRespond(FilterResponseEvent $event) { if ($response->isClientError()) { $http_4xx_response_cacheability = new CacheableMetadata(); $http_4xx_response_cacheability->setCacheTags(['4xx-response']); - $response->addCacheabilityDependency($http_4xx_response_cacheability); + $response->addCacheableDependency($http_4xx_response_cacheability); } } diff --git a/core/lib/Drupal/Core/EventSubscriber/RouteAccessResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/RouteAccessResponseSubscriber.php index 291809e..76784e7 100644 --- a/core/lib/Drupal/Core/EventSubscriber/RouteAccessResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/RouteAccessResponseSubscriber.php @@ -46,7 +46,7 @@ public function onRespond(FilterResponseEvent $event) { $request = $event->getRequest(); $access_result = $request->attributes->get(AccessAwareRouterInterface::ACCESS_RESULT); - $response->addCacheabilityDependency($access_result); + $response->addCacheableDependency($access_result); } /** diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php index 3232a27..e945eca 100644 --- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php @@ -164,7 +164,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch // arrays to the response. foreach (['page_top', 'page', 'page_bottom'] as $region) { if (isset($html[$region])) { - $response->addCacheabilityDependency(CacheableMetadata::createFromRenderArray($html[$region])); + $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($html[$region])); } } @@ -172,7 +172,7 @@ public function renderResponse(array $main_content, Request $request, RouteMatch // entire render cache, regardless of the cache bin. $default = new CacheableMetadata(); $default->setCacheTags(['rendered']); - $response->addCacheabilityDependency($default); + $response->addCacheableDependency($default); return $response; } diff --git a/core/lib/Drupal/Core/Render/Renderer.php b/core/lib/Drupal/Core/Render/Renderer.php index c6a8ca0e..919b7c2 100644 --- a/core/lib/Drupal/Core/Render/Renderer.php +++ b/core/lib/Drupal/Core/Render/Renderer.php @@ -800,7 +800,7 @@ public function mergeBubbleableMetadata(array $a, array $b) { /** * {@inheritdoc} */ - public function addCacheabilityDependency(array &$elements, $dependency) { + public function addCacheableDependency(array &$elements, $dependency) { $meta_a = CacheableMetadata::createFromRenderArray($elements); $meta_b = CacheableMetadata::createFromObject($dependency); $meta_a->merge($meta_b)->applyTo($elements); diff --git a/core/lib/Drupal/Core/Render/RendererInterface.php b/core/lib/Drupal/Core/Render/RendererInterface.php index 552071f..9ffb34f 100644 --- a/core/lib/Drupal/Core/Render/RendererInterface.php +++ b/core/lib/Drupal/Core/Render/RendererInterface.php @@ -355,7 +355,7 @@ public function mergeBubbleableMetadata(array $a, array $b); * @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency * The dependency. */ - public function addCacheabilityDependency(array &$elements, $dependency); + public function addCacheableDependency(array &$elements, $dependency); /** * Merges two attachments arrays (which live under the '#attached' key). diff --git a/core/modules/book/src/BookManager.php b/core/modules/book/src/BookManager.php index 2ebc4a7..aab9611 100644 --- a/core/modules/book/src/BookManager.php +++ b/core/modules/book/src/BookManager.php @@ -362,7 +362,7 @@ protected function addParentSelectFormElements(array $book_link) { '#suffix' => '', ); } - $this->renderer->addCacheabilityDependency($form, $config); + $this->renderer->addCacheableDependency($form, $config); return $form; } diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php index da04da6..9f47519 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php @@ -225,9 +225,9 @@ public function form(array $form, FormStateInterface $form_state) { '#access' => $is_admin, ); - $this->renderer->addCacheabilityDependency($form, $config); + $this->renderer->addCacheableDependency($form, $config); // The form depends on the field definition. - $this->renderer->addCacheabilityDependency($form, $field_definition->getConfig($entity->bundle())); + $this->renderer->addCacheableDependency($form, $field_definition->getConfig($entity->bundle())); return parent::form($form, $form_state, $comment); } diff --git a/core/modules/contact/src/Controller/ContactController.php b/core/modules/contact/src/Controller/ContactController.php index 42a25a0..7233bb8 100644 --- a/core/modules/contact/src/Controller/ContactController.php +++ b/core/modules/contact/src/Controller/ContactController.php @@ -89,7 +89,7 @@ public function contactSitePage(ContactFormInterface $contact_form = NULL) { $form = $this->entityFormBuilder()->getForm($message); $form['#title'] = SafeMarkup::checkPlain($contact_form->label()); $form['#cache']['contexts'][] = 'user.permissions'; - $this->renderer->addCacheabilityDependency($form, $config); + $this->renderer->addCacheableDependency($form, $config); return $form; } diff --git a/core/modules/forum/src/Controller/ForumController.php b/core/modules/forum/src/Controller/ForumController.php index c018649..20a13de 100644 --- a/core/modules/forum/src/Controller/ForumController.php +++ b/core/modules/forum/src/Controller/ForumController.php @@ -203,7 +203,7 @@ protected function build($forums, TermInterface $term, $topics = array(), $paren if (empty($term->forum_container->value)) { $build['#attached']['feed'][] = array('taxonomy/term/' . $term->id() . '/feed', 'RSS - ' . $term->getName()); } - $this->renderer->addCacheabilityDependency($build, $config); + $this->renderer->addCacheableDependency($build, $config); return [ 'action' => $this->buildActionLinks($config->get('vocabulary'), $term), diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index 297ffdd..448a353 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -58,7 +58,7 @@ public function get(EntityInterface $entity) { $response = new ResourceResponse($entity, 200); // Make the response use the entity's cacheability metadata. // @todo include access cacheability metadata, for the access checks above. - $response->addCacheabilityDependency($entity); + $response->addCacheableDependency($entity); return $response; } diff --git a/core/modules/rest/src/RequestHandler.php b/core/modules/rest/src/RequestHandler.php index c0aa2c4..f8f408f 100644 --- a/core/modules/rest/src/RequestHandler.php +++ b/core/modules/rest/src/RequestHandler.php @@ -110,7 +110,7 @@ public function handle(RouteMatchInterface $route_match, Request $request) { $response->setContent($output); $response->headers->set('Content-Type', $request->getMimeType($format)); // Add rest settings config's cache tags. - $response->addCacheabilityDependency($this->container->get('config.factory')->get('rest.settings')); + $response->addCacheableDependency($this->container->get('config.factory')->get('rest.settings')); } return $response; } diff --git a/core/modules/rest/src/ResourceResponse.php b/core/modules/rest/src/ResourceResponse.php index 89f0e01..2919fb1 100644 --- a/core/modules/rest/src/ResourceResponse.php +++ b/core/modules/rest/src/ResourceResponse.php @@ -7,7 +7,6 @@ namespace Drupal\rest; -use Drupal\Core\Cache\CacheableResponse; use Drupal\Core\Cache\CacheableResponseInterface; use Drupal\Core\Cache\CacheableResponseTrait; use Symfony\Component\HttpFoundation\Response; diff --git a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php index 0a64993..5ac7ca0 100644 --- a/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php +++ b/core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php @@ -287,7 +287,7 @@ public function permissionDependentContent() { // The content depends on the access result. $access = AccessResult::allowedIfHasPermission($this->currentUser, 'pet llamas'); - $this->renderer->addCacheabilityDependency($build, $access); + $this->renderer->addCacheableDependency($build, $access); // Build the content. if ($access->isAllowed()) { diff --git a/core/modules/user/src/Form/UserLoginForm.php b/core/modules/user/src/Form/UserLoginForm.php index 6d8db0d..94ec9cf 100644 --- a/core/modules/user/src/Form/UserLoginForm.php +++ b/core/modules/user/src/Form/UserLoginForm.php @@ -124,7 +124,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['#validate'][] = '::validateAuthentication'; $form['#validate'][] = '::validateFinal'; - $this->renderer->addCacheabilityDependency($form, $config); + $this->renderer->addCacheableDependency($form, $config); return $form; } diff --git a/core/tests/Drupal/Tests/Core/Render/RendererTest.php b/core/tests/Drupal/Tests/Core/Render/RendererTest.php index ed394f8..9b6ec0b 100644 --- a/core/tests/Drupal/Tests/Core/Render/RendererTest.php +++ b/core/tests/Drupal/Tests/Core/Render/RendererTest.php @@ -622,16 +622,16 @@ public function providerTestRenderCacheMaxAge() { } /** - * @covers ::addDependency + * @covers ::addCacheableDependency * - * @dataProvider providerTestAddDependency + * @dataProvider providerTestAddCacheableDependency */ - public function testAddDependency(array $build, $object, array $expected) { - $this->renderer->addCacheabilityDependency($build, $object); + public function testAddCacheableDependency(array $build, $object, array $expected) { + $this->renderer->addCacheableDependency($build, $object); $this->assertEquals($build, $expected); } - public function providerTestAddDependency() { + public function providerTestAddCacheableDependency() { return [ // Empty render array, typical default cacheability. [