diff -u b/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php --- b/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -352,13 +352,13 @@ $base_field_definitions = $this->getBaseFieldDefinitions($entity_type_id); // Not prepared, try to load from cache. $cid = 'entity_bundle_field_definitions:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->id; - if ($cache = $this->cacheBackend->get($cid)) { + if ($cache = $this->cache->get($cid)) { $bundle_field_definitions = $cache->data; } else { // Rebuild the definitions and put it into the cache. $bundle_field_definitions = $this->buildBundleFieldDefinitions($entity_type_id, $bundle, $base_field_definitions); - $this->cacheBackend->set($cid, $bundle_field_definitions, Cache::PERMANENT, array('entity_types' => TRUE, 'entity_field_info' => TRUE)); + $this->cache->set($cid, $bundle_field_definitions, Cache::PERMANENT, array('entity_types' => TRUE, 'entity_field_info' => TRUE)); } // Field definitions consist of the bundle specific overrides and the // base fields, merge them together. Use array_replace() to replace base @@ -374,13 +374,13 @@ $base_field_definitions = $this->getBaseFieldDefinitions($entity_type_id); // Not prepared, try to load from cache. $cid = 'entity_bundle_field_definitions:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->id; - if ($cache = $this->cache->get($cid)) { + if ($cache = $this->cacheBackend->get($cid)) { $bundle_field_definitions = $cache->data; } else { // Rebuild the definitions and put it into the cache. $bundle_field_definitions = $this->buildBundleFieldDefinitions($entity_type_id, $bundle, $base_field_definitions); - $this->cache->set($cid, $bundle_field_definitions, Cache::PERMANENT, array('entity_types' => TRUE, 'entity_field_info' => TRUE)); + $this->cacheBackend->set($cid, $bundle_field_definitions, Cache::PERMANENT, array('entity_types' => TRUE, 'entity_field_info' => TRUE)); } // Field definitions consist of the bundle specific overrides and the // base fields, merge them together. Use array_replace() to replace base @@ -432,7 +432,7 @@ public function getAllBundleInfo() { if (!isset($this->bundleInfo)) { $langcode = $this->languageManager->getCurrentLanguage()->id; - if ($cache = $this->cacheBackend->get("entity_bundle_info:$langcode")) { + if ($cache = $this->cache->get("entity_bundle_info:$langcode")) { $this->bundleInfo = $cache->data; } else { @@ -444,7 +444,7 @@ } } $this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo); - $this->cacheBackend->set("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, array('entity_types' => TRUE)); + $this->cache->set("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, array('entity_types' => TRUE)); } } @@ -475,7 +475,7 @@ public function getAllBundleInfo() { if (!isset($this->bundleInfo)) { $langcode = $this->languageManager->getCurrentLanguage()->id; - if ($cache = $this->cache->get("entity_bundle_info:$langcode")) { + if ($cache = $this->cacheBackend->get("entity_bundle_info:$langcode")) { $this->bundleInfo = $cache->data; } else { @@ -487,7 +487,7 @@ } } $this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo); - $this->cache->set("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, array('entity_types' => TRUE)); + $this->cacheBackend->set("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, array('entity_types' => TRUE)); } } @@ -537,7 +537,7 @@ if (!isset($this->displayModeInfo[$display_type])) { $key = 'entity_' . $display_type . '_info'; $langcode = $this->languageManager->getCurrentLanguage(Language::TYPE_INTERFACE)->id; - if ($cache = $this->cacheBackend->get("$key:$langcode")) { + if ($cache = $this->cache->get("$key:$langcode")) { $this->displayModeInfo[$display_type] = $cache->data; } else { @@ -547,7 +547,7 @@ $this->displayModeInfo[$display_type][$display_mode_entity_type][$display_mode_name] = (array) $display_mode; } $this->moduleHandler->alter($key, $this->displayModeInfo[$display_type]); - $this->cacheBackend->set("$key:$langcode", $this->displayModeInfo[$display_type], CacheBackendInterface::CACHE_PERMANENT, array('entity_types' => TRUE)); + $this->cache->set("$key:$langcode", $this->displayModeInfo[$display_type], CacheBackendInterface::CACHE_PERMANENT, array('entity_types' => TRUE)); } } @@ -580,7 +580,7 @@ if (!isset($this->displayModeInfo[$display_type])) { $key = 'entity_' . $display_type . '_info'; $langcode = $this->languageManager->getCurrentLanguage(Language::TYPE_INTERFACE)->id; - if ($cache = $this->cache->get("$key:$langcode")) { + if ($cache = $this->cacheBackend->get("$key:$langcode")) { $this->displayModeInfo[$display_type] = $cache->data; } else { @@ -590,7 +590,7 @@ $this->displayModeInfo[$display_type][$display_mode_entity_type][$display_mode_name] = (array) $display_mode; } $this->moduleHandler->alter($key, $this->displayModeInfo[$display_type]); - $this->cache->set("$key:$langcode", $this->displayModeInfo[$display_type], CacheBackendInterface::CACHE_PERMANENT, array('entity_types' => TRUE)); + $this->cacheBackend->set("$key:$langcode", $this->displayModeInfo[$display_type], CacheBackendInterface::CACHE_PERMANENT, array('entity_types' => TRUE)); } } diff -u b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php --- b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -5,7 +5,7 @@ * Contains \Drupal\Tests\Core\Entity\EntityManagerTest. */ -namespace Drupal\Tests\Core\Entity; +namespace Drupal\Tests\Core\Entity { use Drupal\Component\Plugin\Discovery\DiscoveryInterface; use Drupal\Core\DependencyInjection\ContainerBuilder; @@ -684,25 +684,14 @@ 'apple' => $apple, 'banana' => $banana, )); - $this->cache->expects($this->at(0)) - ->method('get') - ->with("entity_bundle_info:en", FALSE) - ->will($this->returnValue(FALSE)); $this->cache->expects($this->at(1)) ->method('get') - ->with("entity_type::en", FALSE) ->will($this->returnValue(FALSE)); $this->cache->expects($this->at(2)) - ->method('set'); - $this->cache->expects($this->at(3)) - ->method('set'); - $this->cache->expects($this->at(4)) - ->method('deleteTags') - ->with(array('entity_types' => TRUE)); - $this->cache->expects($this->at(5)) ->method('get') - ->with("entity_bundle_info:en", FALSE) ->will($this->returnValue((object) array('data' => 'cached data'))); + $this->cache->expects($this->once()) + ->method('set'); $expected = array( 'apple' => array( @@ -731,14 +720,25 @@ 'apple' => $apple, 'banana' => $banana, )); + $this->cache->expects($this->at(0)) + ->method('get') + ->with("entity_bundle_info:en", FALSE) + ->will($this->returnValue(FALSE)); $this->cache->expects($this->at(1)) ->method('get') + ->with("entity_type::en", FALSE) ->will($this->returnValue(FALSE)); $this->cache->expects($this->at(2)) + ->method('set'); + $this->cache->expects($this->at(3)) + ->method('set'); + $this->cache->expects($this->at(4)) + ->method('deleteTags') + ->with(array('entity_types' => TRUE)); + $this->cache->expects($this->at(5)) ->method('get') + ->with("entity_bundle_info:en", FALSE) ->will($this->returnValue((object) array('data' => 'cached data'))); - $this->cache->expects($this->once()) - ->method('set'); $expected = array( 'apple' => array( @@ -979,0 +980,10 @@ +} + +namespace { + + /** + * Implements hook_entity_type_build(). + */ + function entity_manager_test_module_entity_type_build() { + } +}