From 985edb154840e07c7beb1918c16005b1091b83ff Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Tue, 21 Oct 2014 09:46:57 +0100 Subject: [PATCH] Issue #2351847 by damiankloip: Fixed Rename getCacheTag() to getCacheTags(). --- core/lib/Drupal/Core/Access/AccessResult.php | 2 +- .../Core/Config/Entity/ConfigEntityBase.php | 2 +- .../Core/Datetime/Entity/DateFormat.php | 2 +- core/lib/Drupal/Core/Entity/Entity.php | 6 ++--- .../Drupal/Core/Entity/EntityInterface.php | 2 +- .../Drupal/Core/Entity/EntityViewBuilder.php | 8 +++---- .../Entity/EntityViewBuilderInterface.php | 2 +- core/modules/aggregator/src/Entity/Item.php | 6 ++--- .../src/Plugin/Block/AggregatorFeedBlock.php | 2 +- .../src/Tests/ItemCacheTagsTest.php | 2 +- core/modules/block/src/BlockViewBuilder.php | 4 ++-- core/modules/block/src/Entity/Block.php | 6 ++--- .../src/Plugin/CKEditorPlugin/Internal.php | 2 +- ...ontentTranslationManageAccessCheckTest.php | 2 +- .../src/Plugin/Filter/EditorFileReference.php | 2 +- .../EntityReferenceIdFormatter.php | 2 +- .../EntityReferenceLabelFormatter.php | 2 +- .../Tests/EntityReferenceFormatterTest.php | 8 +++---- .../filter/src/Element/ProcessedText.php | 2 +- .../filter/src/FilterProcessResult.php | 2 +- core/modules/image/src/Entity/ImageStyle.php | 2 +- .../Field/FieldFormatter/ImageFormatter.php | 2 +- .../ResponsiveImageFormatter.php | 4 ++-- .../src/Controller/SearchController.php | 2 +- core/modules/shortcut/shortcut.module | 2 +- core/modules/shortcut/src/Entity/Shortcut.php | 6 ++--- core/modules/system/core.api.php | 2 +- .../Tests/Entity/EntityCacheTagsTestBase.php | 22 +++++++++---------- .../Entity/EntityWithUriCacheTagsTestBase.php | 6 ++--- .../src/Controller/EntityTestController.php | 2 +- .../Field/FieldFormatter/LinkFormatter.php | 2 +- .../src/Tests/Formatter/TextFormatterTest.php | 2 +- core/modules/tour/src/TourViewBuilder.php | 2 +- .../Field/FieldFormatter/AuthorFormatter.php | 2 +- core/modules/views_ui/src/ViewUI.php | 4 ++-- .../Tests/Core/Access/AccessResultTest.php | 2 +- 36 files changed, 65 insertions(+), 65 deletions(-) diff --git a/core/lib/Drupal/Core/Access/AccessResult.php b/core/lib/Drupal/Core/Access/AccessResult.php index 7dc8688f4523..329d50d14fac 100644 --- a/core/lib/Drupal/Core/Access/AccessResult.php +++ b/core/lib/Drupal/Core/Access/AccessResult.php @@ -356,7 +356,7 @@ abstract class AccessResult implements AccessResultInterface, CacheableInterface * @return $this */ public function cacheUntilEntityChanges(EntityInterface $entity) { - $this->addCacheTags($entity->getCacheTag()); + $this->addCacheTags($entity->getCacheTags()); return $this; } diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 86a52357c8cb..7ea23bdea56b 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -163,7 +163,7 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface */ public function disable() { // An entity was disabled, invalidate its own cache tag. - Cache::invalidateTags($this->getCacheTag()); + Cache::invalidateTags($this->getCacheTags()); return $this->setStatus(FALSE); } diff --git a/core/lib/Drupal/Core/Datetime/Entity/DateFormat.php b/core/lib/Drupal/Core/Datetime/Entity/DateFormat.php index 5eb0faf5bf8e..f8bb4426297f 100644 --- a/core/lib/Drupal/Core/Datetime/Entity/DateFormat.php +++ b/core/lib/Drupal/Core/Datetime/Entity/DateFormat.php @@ -95,7 +95,7 @@ class DateFormat extends ConfigEntityBase implements DateFormatInterface { /** * {@inheritdoc} */ - public function getCacheTag() { + public function getCacheTags() { return ['rendered']; } diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 558297b66c99..bd00eceb67bf 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -424,7 +424,7 @@ abstract class Entity implements EntityInterface { /** * {@inheritdoc} */ - public function getCacheTag() { + public function getCacheTags() { // @todo Add bundle-specific listing cache tag? https://drupal.org/node/2145751 return [$this->entityTypeId . ':' . $this->id()]; } @@ -467,7 +467,7 @@ abstract class Entity implements EntityInterface { $tags = $this->getEntityType()->getListCacheTags(); if ($update) { // An existing entity was updated, also invalidate its unique cache tag. - $tags = Cache::mergeTags($tags, $this->getCacheTag()); + $tags = Cache::mergeTags($tags, $this->getCacheTags()); $this->onUpdateBundleEntity(); } Cache::invalidateTags($tags); @@ -489,7 +489,7 @@ abstract class Entity implements EntityInterface { // other pages than the one it's on. The one it's on is handled by its own // cache tag, but subsequent list pages would not be invalidated, hence we // must invalidate its list cache tags as well.) - $tags = Cache::mergeTags($tags, $entity->getCacheTag()); + $tags = Cache::mergeTags($tags, $entity->getCacheTags()); } Cache::invalidateTags($tags); } diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index 8f105e45f31f..ae0e85eaaa2f 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -402,6 +402,6 @@ interface EntityInterface extends AccessibleInterface { * @return array * An array of cache tags. */ - public function getCacheTag(); + public function getCacheTags(); } diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index e31c13324219..8330590f2494 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -159,7 +159,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf '#langcode' => $langcode, // Collect cache defaults for this entity. '#cache' => array( - 'tags' => Cache::mergeTags($this->getCacheTag(), $entity->getCacheTag()), + 'tags' => Cache::mergeTags($this->getCacheTags(), $entity->getCacheTags()), ), ); @@ -341,7 +341,7 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf /** * {@inheritdoc} */ - public function getCacheTag() { + public function getCacheTags() { return array($this->entityTypeId . '_view'); } @@ -362,12 +362,12 @@ class EntityViewBuilder extends EntityHandlerBase implements EntityHandlerInterf if (isset($entities)) { $tags = []; foreach ($entities as $entity) { - $tags = Cache::mergeTags($tags, $entity->getCacheTag(), $entity->getEntityType()->getListCacheTags()); + $tags = Cache::mergeTags($tags, $entity->getCacheTags(), $entity->getEntityType()->getListCacheTags()); } Cache::invalidateTags($tags); } else { - Cache::invalidateTags($this->getCacheTag()); + Cache::invalidateTags($this->getCacheTags()); } } diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php b/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php index eca51960cb19..27a1c8793c8e 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilderInterface.php @@ -157,6 +157,6 @@ interface EntityViewBuilderInterface { * @return array * An array of cache tags. */ - public function getCacheTag(); + public function getCacheTags(); } diff --git a/core/modules/aggregator/src/Entity/Item.php b/core/modules/aggregator/src/Entity/Item.php index 09eed9b66d7d..066b7ff4d64f 100644 --- a/core/modules/aggregator/src/Entity/Item.php +++ b/core/modules/aggregator/src/Entity/Item.php @@ -223,14 +223,14 @@ class Item extends ContentEntityBase implements ItemInterface { // handles the regular cases. The Item entity has one special case: a newly // created Item is *also* associated with a Feed, so we must invalidate the // associated Feed's cache tag. - Cache::invalidateTags($this->getCacheTag()); + Cache::invalidateTags($this->getCacheTags()); } /** * {@inheritdoc} */ - public function getCacheTag() { - return Feed::load($this->getFeedId())->getCacheTag(); + public function getCacheTags() { + return Feed::load($this->getFeedId())->getCacheTags(); } diff --git a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php index 2710cedb86bb..16ca1affa117 100644 --- a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php +++ b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php @@ -195,7 +195,7 @@ class AggregatorFeedBlock extends BlockBase implements ContainerFactoryPluginInt public function getCacheTags() { $cache_tags = parent::getCacheTags(); $feed = $this->feedStorage->load($this->configuration['feed']); - return Cache::mergeTags($cache_tags, $feed->getCacheTag()); + return Cache::mergeTags($cache_tags, $feed->getCacheTags()); } } diff --git a/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php b/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php index 3a80ebe36d1e..f79a53cc2b43 100644 --- a/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php +++ b/core/modules/aggregator/src/Tests/ItemCacheTagsTest.php @@ -72,7 +72,7 @@ class ItemCacheTagsTest extends EntityCacheTagsTestBase { */ public function testEntityCreation() { // Create a cache entry that is tagged with a feed cache tag. - \Drupal::cache('render')->set('foo', 'bar', \Drupal\Core\Cache\CacheBackendInterface::CACHE_PERMANENT, $this->entity->getCacheTag()); + \Drupal::cache('render')->set('foo', 'bar', \Drupal\Core\Cache\CacheBackendInterface::CACHE_PERMANENT, $this->entity->getCacheTags()); // Verify a cache hit. $this->verifyRenderCache('foo', array('aggregator_feed:1')); diff --git a/core/modules/block/src/BlockViewBuilder.php b/core/modules/block/src/BlockViewBuilder.php index 32d75cff3425..8c781c1e41a5 100644 --- a/core/modules/block/src/BlockViewBuilder.php +++ b/core/modules/block/src/BlockViewBuilder.php @@ -71,8 +71,8 @@ class BlockViewBuilder extends EntityViewBuilder { // Set cache tags; these always need to be set, whether the block is // cacheable or not, so that the page cache is correctly informed. $build[$entity_id]['#cache']['tags'] = Cache::mergeTags( - $this->getCacheTag(), // Block view builder cache tag. - $entity->getCacheTag(), // Block entity cache tag. + $this->getCacheTags(), // Block view builder cache tag. + $entity->getCacheTags(), // Block entity cache tag. $plugin->getCacheTags() // Block plugin cache tags. ); diff --git a/core/modules/block/src/Entity/Block.php b/core/modules/block/src/Entity/Block.php index 92793f8fd751..6f7f27692caa 100644 --- a/core/modules/block/src/Entity/Block.php +++ b/core/modules/block/src/Entity/Block.php @@ -166,7 +166,7 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin // so we must invalidate the associated block's cache tag (which includes // the theme cache tag). if (!$update) { - Cache::invalidateTags($this->getCacheTag()); + Cache::invalidateTags($this->getCacheTags()); } } @@ -179,8 +179,8 @@ class Block extends ConfigEntityBase implements BlockInterface, EntityWithPlugin * appear there currently. Hence a block configuration entity must also return * the associated theme's cache tag. */ - public function getCacheTag() { - return Cache::mergeTags(parent::getCacheTag(), ['theme:' . $this->theme]); + public function getCacheTags() { + return Cache::mergeTags(parent::getCacheTags(), ['theme:' . $this->theme]); } /** diff --git a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php index aa31023b84b4..d64c80670230 100644 --- a/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php +++ b/core/modules/ckeditor/src/Plugin/CKEditorPlugin/Internal.php @@ -336,7 +336,7 @@ class Internal extends CKEditorPluginBase implements ContainerFactoryPluginInter // Cache the "format_tags" configuration. This cache item is infinitely // valid; it only changes whenever the text format is changed, hence it's // tagged with the text format's cache tag. - $this->cache->set($cid, $format_tags, Cache::PERMANENT, $format->getCacheTag()); + $this->cache->set($cid, $format_tags, Cache::PERMANENT, $format->getCacheTags()); } return $format_tags; diff --git a/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php b/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php index 6d96727354ac..c8657b015862 100644 --- a/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php +++ b/core/modules/content_translation/tests/src/Unit/Access/ContentTranslationManageAccessCheckTest.php @@ -70,7 +70,7 @@ class ContentTranslationManageAccessCheckTest extends UnitTestCase { ->with() ->will($this->returnValue(array())); $entity->expects($this->once()) - ->method('getCacheTag') + ->method('getCacheTags') ->will($this->returnValue(array('node:1337'))); // Set the route requirements. diff --git a/core/modules/editor/src/Plugin/Filter/EditorFileReference.php b/core/modules/editor/src/Plugin/Filter/EditorFileReference.php index b22bda60486b..5315b78c4cd7 100644 --- a/core/modules/editor/src/Plugin/Filter/EditorFileReference.php +++ b/core/modules/editor/src/Plugin/Filter/EditorFileReference.php @@ -82,7 +82,7 @@ class EditorFileReference extends FilterBase implements ContainerFactoryPluginIn $file = $this->entityManager->loadEntityByUuid('file', $uuid); if ($file) { - $result->addCacheTags($file->getCacheTag()); + $result->addCacheTags($file->getCacheTags()); } } } diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php index bd22eeaedb65..98c316680aa7 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceIdFormatter.php @@ -38,7 +38,7 @@ class EntityReferenceIdFormatter extends EntityReferenceFormatterBase { // that the referenced entity is deleted, the cache for referring // entities must be cleared. '#cache' => array( - 'tags' => $entity->getCacheTag(), + 'tags' => $entity->getCacheTags(), ), ); } diff --git a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php index 61abdb6818f2..238d47b47530 100644 --- a/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php +++ b/core/modules/entity_reference/src/Plugin/Field/FieldFormatter/EntityReferenceLabelFormatter.php @@ -85,7 +85,7 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase { else { $elements[$delta] = array('#markup' => String::checkPlain($label)); } - $elements[$delta]['#cache']['tags'] = $entity->getCacheTag(); + $elements[$delta]['#cache']['tags'] = $entity->getCacheTags(); } return $elements; diff --git a/core/modules/entity_reference/src/Tests/EntityReferenceFormatterTest.php b/core/modules/entity_reference/src/Tests/EntityReferenceFormatterTest.php index bf0ae4661520..d51da8caefad 100644 --- a/core/modules/entity_reference/src/Tests/EntityReferenceFormatterTest.php +++ b/core/modules/entity_reference/src/Tests/EntityReferenceFormatterTest.php @@ -143,7 +143,7 @@ class EntityReferenceFormatterTest extends EntityUnitTestBase { $build = $items->view(array('type' => $formatter)); $this->assertEqual($build[0]['#markup'], $this->referencedEntity->id(), format_string('The markup returned by the @formatter formatter is correct.', array('@formatter' => $formatter))); - $this->assertEqual($build[0]['#cache']['tags'], $this->referencedEntity->getCacheTag(), format_string('The @formatter formatter has the expected cache tags.', array('@formatter' => $formatter))); + $this->assertEqual($build[0]['#cache']['tags'], $this->referencedEntity->getCacheTags(), format_string('The @formatter formatter has the expected cache tags.', array('@formatter' => $formatter))); } @@ -180,9 +180,9 @@ class EntityReferenceFormatterTest extends EntityUnitTestBase { drupal_render($build[0]); $this->assertEqual($build[0]['#markup'], 'default | ' . $this->referencedEntity->label() . $expected_rendered_name_field . $expected_rendered_body_field, format_string('The markup returned by the @formatter formatter is correct.', array('@formatter' => $formatter))); $expected_cache_tags = Cache::mergeTags( - \Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTag(), - $this->referencedEntity->getCacheTag(), - FilterFormat::load('full_html')->getCacheTag() + \Drupal::entityManager()->getViewBuilder($this->entityType)->getCacheTags(), + $this->referencedEntity->getCacheTags(), + FilterFormat::load('full_html')->getCacheTags() ); $this->assertEqual($build[0]['#cache']['tags'], $expected_cache_tags, format_string('The @formatter formatter has the expected cache tags.', array('@formatter' => $formatter))); } diff --git a/core/modules/filter/src/Element/ProcessedText.php b/core/modules/filter/src/Element/ProcessedText.php index b4a0eb06f9bb..0779f51bbf30 100644 --- a/core/modules/filter/src/Element/ProcessedText.php +++ b/core/modules/filter/src/Element/ProcessedText.php @@ -129,7 +129,7 @@ class ProcessedText extends RenderElement { $cache_tags = Cache::mergeTags($cache_tags, $element['#cache']['tags']); } // Prepend the text format's cache tags array. - $cache_tags = Cache::mergeTags($cache_tags, $format->getCacheTag()); + $cache_tags = Cache::mergeTags($cache_tags, $format->getCacheTags()); $element['#cache']['tags'] = $cache_tags; // Collect all attached assets. diff --git a/core/modules/filter/src/FilterProcessResult.php b/core/modules/filter/src/FilterProcessResult.php index 5597271e0888..5ad48c1bca30 100644 --- a/core/modules/filter/src/FilterProcessResult.php +++ b/core/modules/filter/src/FilterProcessResult.php @@ -49,7 +49,7 @@ use Drupal\Core\Cache\Cache; * )); * * // Associate cache tags to be invalidated by. - * $result->setCacheTags($node->getCacheTag()); + * $result->setCacheTags($node->getCacheTags()); * * return $result; * } diff --git a/core/modules/image/src/Entity/ImageStyle.php b/core/modules/image/src/Entity/ImageStyle.php index 5811c0ec650a..32e5d3b1f4e6 100644 --- a/core/modules/image/src/Entity/ImageStyle.php +++ b/core/modules/image/src/Entity/ImageStyle.php @@ -262,7 +262,7 @@ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, Entity // Clear caches so that formatters may be added for this style. drupal_theme_rebuild(); - Cache::invalidateTags($this->getCacheTag()); + Cache::invalidateTags($this->getCacheTags()); return $this; } diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php index 069178df434b..7e873658beba 100644 --- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php +++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php @@ -119,7 +119,7 @@ class ImageFormatter extends ImageFormatterBase { $cache_tags = array(); if (!empty($image_style_setting)) { $image_style = entity_load('image_style', $image_style_setting); - $cache_tags = $image_style->getCacheTag(); + $cache_tags = $image_style->getCacheTags(); } foreach ($items as $delta => $item) { diff --git a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php index 109df24a08be..a1308e98c02e 100644 --- a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php +++ b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php @@ -198,7 +198,7 @@ class ResponsiveImageFormatter extends ImageFormatterBase implements ContainerFa } $cache_tags = []; if ($responsive_image_mapping) { - $cache_tags = Cache::mergeTags($cache_tags, $responsive_image_mapping->getCacheTag()); + $cache_tags = Cache::mergeTags($cache_tags, $responsive_image_mapping->getCacheTags()); foreach ($responsive_image_mapping->getMappings() as $mapping) { // First mapping found is used as fallback. if (empty($fallback_image_style)) { @@ -209,7 +209,7 @@ class ResponsiveImageFormatter extends ImageFormatterBase implements ContainerFa } $image_styles = entity_load_multiple('image_style', $image_styles_to_load); foreach ($image_styles as $image_style) { - $cache_tags = Cache::mergeTags($cache_tags, $image_style->getCacheTag()); + $cache_tags = Cache::mergeTags($cache_tags, $image_style->getCacheTags()); } foreach ($items as $delta => $item) { diff --git a/core/modules/search/src/Controller/SearchController.php b/core/modules/search/src/Controller/SearchController.php index b3b112262606..4e79f79f63a3 100644 --- a/core/modules/search/src/Controller/SearchController.php +++ b/core/modules/search/src/Controller/SearchController.php @@ -129,7 +129,7 @@ class SearchController extends ControllerBase { ), ), '#cache' => array( - 'tags' => $entity->getCacheTag(), + 'tags' => $entity->getCacheTags(), ), ); diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index e0b11ea9c2af..a90b79e3b2a7 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -260,7 +260,7 @@ function shortcut_renderable_links($shortcut_set = NULL) { 'title' => $shortcut->label(), 'url' => Url::fromRoute($shortcut->getRouteName(), $shortcut->getRouteParameters()), ); - $cache_tags = Cache::mergeTags($cache_tags, $shortcut->getCacheTag()); + $cache_tags = Cache::mergeTags($cache_tags, $shortcut->getCacheTags()); } if (!empty($links)) { diff --git a/core/modules/shortcut/src/Entity/Shortcut.php b/core/modules/shortcut/src/Entity/Shortcut.php index 087b6501ab20..770406a8e897 100644 --- a/core/modules/shortcut/src/Entity/Shortcut.php +++ b/core/modules/shortcut/src/Entity/Shortcut.php @@ -160,7 +160,7 @@ class Shortcut extends ContentEntityBase implements ShortcutInterface { // newly created shortcut is *also* added to a shortcut set, so we must // invalidate the associated shortcut set's cache tag. if (!$update) { - Cache::invalidateTags($this->getCacheTag()); + Cache::invalidateTags($this->getCacheTags()); } } @@ -232,8 +232,8 @@ class Shortcut extends ContentEntityBase implements ShortcutInterface { /** * {@inheritdoc} */ - public function getCacheTag() { - return $this->shortcut_set->entity->getCacheTag(); + public function getCacheTags() { + return $this->shortcut_set->entity->getCacheTags(); } } diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php index 84175109b69a..5983876a9977 100644 --- a/core/modules/system/core.api.php +++ b/core/modules/system/core.api.php @@ -483,7 +483,7 @@ * This also is the case when you define your own entity types: you'll get the * exact same cache tag invalidation as any of the built-in entity types, with * the ability to override any of the default behavior if needed. - * See \Drupal\Core\Entity\EntityInterface::getCacheTag(), + * See \Drupal\Core\Entity\EntityInterface::getCacheTags(), * \Drupal\Core\Entity\EntityTypeInterface::getListCacheTags(), * \Drupal\Core\Entity\Entity::invalidateTagsOnSave() and * \Drupal\Core\Entity\Entity::invalidateTagsOnDelete(). diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php index f0185398bd68..adb444ac1c29 100644 --- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php @@ -287,21 +287,21 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { $view_cache_tag = array(); if ($this->entity->getEntityType()->hasHandlerClass('view_builder')) { $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type) - ->getCacheTag(); + ->getCacheTags(); } // Generate the cache tags for the (non) referencing entities. $referencing_entity_cache_tags = Cache::mergeTags( - $this->referencing_entity->getCacheTag(), - \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTag(), + $this->referencing_entity->getCacheTags(), + \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags(), // Includes the main entity's cache tags, since this entity references it. - $this->entity->getCacheTag(), + $this->entity->getCacheTags(), $this->getAdditionalCacheTagsForEntity($this->entity), $view_cache_tag ); $non_referencing_entity_cache_tags = Cache::mergeTags( - $this->non_referencing_entity->getCacheTag(), - \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTag() + $this->non_referencing_entity->getCacheTags(), + \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags() ); // Generate the cache tags for all two possible entity listing paths. @@ -314,7 +314,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { ); $nonempty_entity_listing_cache_tags = Cache::mergeTags( $this->entity->getEntityType()->getListCacheTags(), - $this->entity->getCacheTag(), + $this->entity->getCacheTags(), $this->getAdditionalCacheTagsForEntityListing($this->entity), $theme_cache_tags, $render_cache_tags @@ -444,7 +444,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { $this->verifyPageCache($non_referencing_entity_path, 'HIT'); // Special case: entity types may choose to use their bundle entity type // cache tags, to avoid having excessively granular invalidation. - $is_special_case = $bundle_entity->getCacheTag() == $this->entity->getCacheTag() && $bundle_entity->getEntityType()->getListCacheTags() == $this->entity->getEntityType()->getListCacheTags(); + $is_special_case = $bundle_entity->getCacheTags() == $this->entity->getCacheTags() && $bundle_entity->getEntityType()->getListCacheTags() == $this->entity->getEntityType()->getListCacheTags(); if ($is_special_case) { $this->verifyPageCache($empty_entity_listing_path, 'MISS'); $this->verifyPageCache($nonempty_entity_listing_path, 'MISS'); @@ -504,7 +504,7 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { // a cache miss for every route except the ones for the non-referencing // entity and the empty entity listing. $this->pass("Test invalidation of referenced entity's cache tag.", 'Debug'); - Cache::invalidateTags($this->entity->getCacheTag()); + Cache::invalidateTags($this->entity->getCacheTags()); $this->verifyPageCache($referencing_entity_path, 'MISS'); $this->verifyPageCache($listing_path, 'MISS'); $this->verifyPageCache($nonempty_entity_listing_path, 'MISS'); @@ -561,8 +561,8 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { // Verify cache hits. $referencing_entity_cache_tags = Cache::mergeTags( - $this->referencing_entity->getCacheTag(), - \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTag() + $this->referencing_entity->getCacheTags(), + \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags() ); $tags = Cache::mergeTags($render_cache_tags, $theme_cache_tags, $referencing_entity_cache_tags); $this->verifyPageCache($referencing_entity_path, 'HIT', $tags); diff --git a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php index d2ef4dd9f064..a40ff8e67473 100644 --- a/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityWithUriCacheTagsTestBase.php @@ -29,8 +29,8 @@ abstract class EntityWithUriCacheTagsTestBase extends EntityCacheTagsTestBase { $view_mode = $this->selectViewMode($entity_type); // Generate the standardized entity cache tags. - $cache_tag = $this->entity->getCacheTag(); - $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type)->getCacheTag(); + $cache_tag = $this->entity->getCacheTags(); + $view_cache_tag = \Drupal::entityManager()->getViewBuilder($entity_type)->getCacheTags(); $render_cache_tag = 'rendered'; @@ -110,7 +110,7 @@ abstract class EntityWithUriCacheTagsTestBase extends EntityCacheTagsTestBase { // Verify that after invalidating the entity's cache tag directly, there is // a cache miss. $this->pass("Test invalidation of entity's cache tag.", 'Debug'); - Cache::invalidateTags($this->entity->getCacheTag()); + Cache::invalidateTags($this->entity->getCacheTags()); $this->verifyPageCache($entity_path, 'MISS'); // Verify a cache hit. diff --git a/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php b/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php index 8154d53d2dd6..75fa1c1755a1 100644 --- a/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php +++ b/core/modules/system/tests/modules/entity_test/src/Controller/EntityTestController.php @@ -150,7 +150,7 @@ class EntityTestController extends ControllerBase { $labels = []; foreach ($entities as $entity) { $labels[] = $entity->label(); - $cache_tags = Cache::mergeTags($cache_tags, $entity->getCacheTag()); + $cache_tags = Cache::mergeTags($cache_tags, $entity->getCacheTags()); } // Always associate the list cache tag, otherwise the cached empty result // wouldn't be invalidated. This would continue to show nothing matches the diff --git a/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/LinkFormatter.php index ec1f86283f80..f14eb9196d58 100644 --- a/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -55,7 +55,7 @@ class LinkFormatter extends TaxonomyFormatterBase { unset($item->_attributes); } - $elements[$delta]['#cache']['tags'] = $item->entity->getCacheTag(); + $elements[$delta]['#cache']['tags'] = $item->entity->getCacheTags(); } } diff --git a/core/modules/text/src/Tests/Formatter/TextFormatterTest.php b/core/modules/text/src/Tests/Formatter/TextFormatterTest.php index 293926ffc03c..cae892ee64e3 100644 --- a/core/modules/text/src/Tests/Formatter/TextFormatterTest.php +++ b/core/modules/text/src/Tests/Formatter/TextFormatterTest.php @@ -92,7 +92,7 @@ class TextFormatterTest extends EntityUnitTestBase { $build = $entity->get('formatted_text')->view(array('type' => $formatter)); drupal_render($build[0]); $this->assertEqual($build[0]['#markup'], "

Hello, world!

\n"); - $this->assertEqual($build[0]['#cache']['tags'], FilterFormat::load('my_text_format')->getCacheTag(), format_string('The @formatter formatter has the expected cache tags when formatting a formatted text field.', array('@formatter' => $formatter))); + $this->assertEqual($build[0]['#cache']['tags'], FilterFormat::load('my_text_format')->getCacheTags(), format_string('The @formatter formatter has the expected cache tags when formatting a formatted text field.', array('@formatter' => $formatter))); } } diff --git a/core/modules/tour/src/TourViewBuilder.php b/core/modules/tour/src/TourViewBuilder.php index 6f2fa27ee5c2..6180bd5065f7 100644 --- a/core/modules/tour/src/TourViewBuilder.php +++ b/core/modules/tour/src/TourViewBuilder.php @@ -65,7 +65,7 @@ class TourViewBuilder extends EntityViewBuilder { ), ), '#cache' => [ - 'tags' => $entity->getCacheTag(), + 'tags' => $entity->getCacheTags(), ], ); } diff --git a/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php b/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php index e30a0bfb6849..45f7a09ceda0 100644 --- a/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php +++ b/core/modules/user/src/Plugin/Field/FieldFormatter/AuthorFormatter.php @@ -39,7 +39,7 @@ class AuthorFormatter extends FormatterBase { '#account' => $referenced_user, '#link_options' => array('attributes' => array('rel' => 'author')), '#cache' => array( - 'tags' => $referenced_user->getCacheTag(), + 'tags' => $referenced_user->getCacheTags(), ), ); } diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 31af29691b40..5c5786d65490 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -1123,8 +1123,8 @@ class ViewUI implements ViewStorageInterface { /** * {@inheritdoc} */ - public function getCacheTag() { - $this->storage->getCacheTag(); + public function getCacheTags() { + $this->storage->getCacheTags(); } /** diff --git a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php index 6f9c6be2dbdd..1213614f5322 100644 --- a/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php +++ b/core/tests/Drupal/Tests/Core/Access/AccessResultTest.php @@ -439,7 +439,7 @@ class AccessResultTest extends UnitTestCase { // ::cacheUntilEntityChanges() convenience method. $node = $this->getMock('\Drupal\node\NodeInterface'); $node->expects($this->any()) - ->method('getCacheTag') + ->method('getCacheTags') ->will($this->returnValue(array('node:20011988'))); $tags = array('node:20011988'); $a = AccessResult::neutral()->addCacheTags($tags);