Commit 985edb15 authored by catch's avatar catch
Browse files

Issue #2351847 by damiankloip: Fixed Rename getCacheTag() to getCacheTags().

parent 84319249
......@@ -356,7 +356,7 @@ public function cachePerUser() {
* @return $this
*/
public function cacheUntilEntityChanges(EntityInterface $entity) {
$this->addCacheTags($entity->getCacheTag());
$this->addCacheTags($entity->getCacheTags());
return $this;
}
......
......@@ -163,7 +163,7 @@ public function enable() {
*/
public function disable() {
// An entity was disabled, invalidate its own cache tag.
Cache::invalidateTags($this->getCacheTag());
Cache::invalidateTags($this->getCacheTags());
return $this->setStatus(FALSE);
}
......
......@@ -95,7 +95,7 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
/**
* {@inheritdoc}
*/
public function getCacheTag() {
public function getCacheTags() {
return ['rendered'];
}
......
......@@ -424,7 +424,7 @@ public function referencedEntities() {
/**
* {@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 @@ protected function invalidateTagsOnSave($update) {
$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 @@ protected static function invalidateTagsOnDelete(EntityTypeInterface $entity_typ
// 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);
}
......
......@@ -402,6 +402,6 @@ public function getTypedData();
* @return array
* An array of cache tags.
*/
public function getCacheTag();
public function getCacheTags();
}
......@@ -159,7 +159,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
'#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 @@ protected function alterBuild(array &$build, EntityInterface $entity, EntityView
/**
* {@inheritdoc}
*/
public function getCacheTag() {
public function getCacheTags() {
return array($this->entityTypeId . '_view');
}
......@@ -362,12 +362,12 @@ public function resetCache(array $entities = NULL) {
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());
}
}
......
......@@ -157,6 +157,6 @@ public function viewFieldItem(FieldItemInterface $item, $display_options = array
* @return array
* An array of cache tags.
*/
public function getCacheTag();
public function getCacheTags();
}
......@@ -223,14 +223,14 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
// 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();
}
......
......@@ -195,7 +195,7 @@ public function build() {
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());
}
}
......@@ -72,7 +72,7 @@ protected function createEntity() {
*/
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'));
......
......@@ -71,8 +71,8 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la
// 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.
);
......
......@@ -166,7 +166,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
// 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 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) {
* 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]);
}
/**
......
......@@ -336,7 +336,7 @@ protected function generateFormatTagsSetting(Editor $editor) {
// 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;
......
......@@ -70,7 +70,7 @@ public function testCreateAccess() {
->with()
->will($this->returnValue(array()));
$entity->expects($this->once())
->method('getCacheTag')
->method('getCacheTags')
->will($this->returnValue(array('node:1337')));
// Set the route requirements.
......
......@@ -82,7 +82,7 @@ public function process($text, $langcode) {
$file = $this->entityManager->loadEntityByUuid('file', $uuid);
if ($file) {
$result->addCacheTags($file->getCacheTag());
$result->addCacheTags($file->getCacheTags());
}
}
}
......
......@@ -38,7 +38,7 @@ public function viewElements(FieldItemListInterface $items) {
// that the referenced entity is deleted, the cache for referring
// entities must be cleared.
'#cache' => array(
'tags' => $entity->getCacheTag(),
'tags' => $entity->getCacheTags(),
),
);
}
......
......@@ -85,7 +85,7 @@ public function viewElements(FieldItemListInterface $items) {
else {
$elements[$delta] = array('#markup' => String::checkPlain($label));
}
$elements[$delta]['#cache']['tags'] = $entity->getCacheTag();
$elements[$delta]['#cache']['tags'] = $entity->getCacheTags();
}
return $elements;
......
......@@ -143,7 +143,7 @@ public function testIdFormatter() {
$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 @@ public function testEntityFormatter() {
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)));
}
......
......@@ -129,7 +129,7 @@ public static function preRenderText($element) {
$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.
......
......@@ -49,7 +49,7 @@
* ));
*
* // Associate cache tags to be invalidated by.
* $result->setCacheTags($node->getCacheTag());
* $result->setCacheTags($node->getCacheTags());
*
* return $result;
* }
......
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