diff --git a/core/lib/Drupal/Core/Cache/StaticCache/StaticCache.php b/core/lib/Drupal/Core/Cache/StaticCache/StaticCache.php index 1be728a..fa61227 100644 --- a/core/lib/Drupal/Core/Cache/StaticCache/StaticCache.php +++ b/core/lib/Drupal/Core/Cache/StaticCache/StaticCache.php @@ -3,7 +3,6 @@ namespace Drupal\Core\Cache\StaticCache; use Drupal\Core\Cache\Cache; - use Drupal\Core\Cache\MemoryBackend; /** @@ -48,15 +47,15 @@ protected function prepareItem($cache, $allow_invalid) { /** * {@inheritdoc} */ - public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = array()) { + public function set($cid, $data, $expire = Cache::PERMANENT, array $tags = []) { assert('\Drupal\Component\Assertion\Inspector::assertAllStrings($tags)', 'Cache Tags must be strings.'); - $this->cache[$cid] = (object) array( + $this->cache[$cid] = (object) [ 'cid' => $cid, 'data' => $data, 'created' => $this->getRequestTime(), 'expire' => $expire, 'tags' => $tags, - ); + ]; } } diff --git a/core/lib/Drupal/Core/Cache/StaticCache/StaticCacheInterface.php b/core/lib/Drupal/Core/Cache/StaticCache/StaticCacheInterface.php index 8c98194..a26ae96 100644 --- a/core/lib/Drupal/Core/Cache/StaticCache/StaticCacheInterface.php +++ b/core/lib/Drupal/Core/Cache/StaticCache/StaticCacheInterface.php @@ -4,7 +4,6 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheTagsInvalidatorInterface; -use Drupal\Core\Cache\StaticCache\StaticCacheInterface; /** * Defines an interface for static cache implementations. diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index ab04e25..399aafe 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -109,6 +109,7 @@ class ConfigEntityStorage extends EntityStorageBase implements ConfigEntityStora * The static cache backend. */ public function __construct(EntityTypeInterface $entity_type, ConfigFactoryInterface $config_factory, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, StaticCacheInterface $static_cache = NULL) { + // @todo Remove this line in Drupal 9.0.x and make $static_cache required. $static_cache = isset($static_cache) ? $static_cache : \Drupal::service('entity.static_cache'); parent::__construct($entity_type, $static_cache); @@ -125,7 +126,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_type, $container->get('config.factory'), $container->get('uuid'), - $container->get('language_manager') + $container->get('language_manager'), + $container->get('entity.static_cache') ); } @@ -324,7 +326,7 @@ protected function has($id, EntityInterface $entity) { * {@inheritdoc} */ protected function getCacheId($id) { - return parent::getCacheId($id) . ':' . $config_overrides_key = $this->overrideFree ? '' : implode(':', $this->configFactory->getCacheKeys()); + return parent::getCacheId($id) . ':' . $this->overrideFree ? '' : implode(':', $this->configFactory->getCacheKeys()); } /** diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index 176a216..2d5cd6b 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -44,10 +44,11 @@ * The entity manager. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend to be used. - * @param \Drupal\Core\Cache\CacheBackendInterface $static_cache - * The cache backend to be used. + * @param \Drupal\Core\Cache\StaticCache\StaticCacheInterface $static_cache + * The static cache backend. */ public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, CacheBackendInterface $cache, StaticCacheInterface $static_cache = NULL) { + // @todo Remove this line in Drupal 9.0.x and make $static_cache required. $static_cache = isset($static_cache) ? $static_cache : \Drupal::service('entity.static_cache'); parent::__construct($entity_type, $static_cache); $this->bundleKey = $this->entityType->getKey('bundle'); @@ -636,7 +637,7 @@ public function resetCache(array $ids = NULL) { if ($ids) { parent::resetCache($ids); if ($this->entityType->isPersistentlyCacheable()) { - $cids = array(); + $cids = []; foreach ($ids as $id) { $cids[] = $this->buildCacheId($id); } diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php index 4ef3c50..009fb8e 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php @@ -76,7 +76,7 @@ /** * The static cache. * - * @var \Drupal\Core\StaticCache\StaticCacheInterface + * @var \Drupal\Core\Cache\StaticCache\StaticCacheInterface */ protected $staticCache; @@ -102,6 +102,7 @@ public function __construct(EntityTypeInterface $entity_type, StaticCacheInterfa $this->uuidKey = $this->entityType->getKey('uuid'); $this->langcodeKey = $this->entityType->getKey('langcode'); $this->entityClass = $this->entityType->getClass(); + // @todo Remove this line in Drupal 9.0.x and make $static_cache required. $this->staticCache = isset($static_cache) ? $static_cache : \Drupal::service('entity.static_cache'); $this->cacheTag = 'entity_static_cache:' . $this->entityTypeId; } @@ -562,4 +563,5 @@ public function getAggregateQuery($conjunction = 'AND') { * The name of the service for the query for this entity storage. */ abstract protected function getQueryServiceName(); + } diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php index 972a047..048052a 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php @@ -61,7 +61,7 @@ class KeyValueEntityStorage extends EntityStorageBase { * The UUID service. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. - * @param \Drupal\Core\StaticCache\StaticCacheInterface $static_cache + * @param \Drupal\Core\Cache\StaticCache\StaticCacheInterface $static_cache * The static cache. */ public function __construct(EntityTypeInterface $entity_type, KeyValueStoreInterface $key_value_store, UuidInterface $uuid_service, LanguageManagerInterface $language_manager, StaticCacheInterface $static_cache = NULL) { @@ -82,7 +82,8 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $entity_type, $container->get('keyvalue')->get('entity_storage__' . $entity_type->id()), $container->get('uuid'), - $container->get('language_manager') + $container->get('language_manager'), + $container->get('entity.static_cache') ); } diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index a5d7245..f2c50b3 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -159,6 +159,7 @@ public function getFieldStorageDefinitions() { * The static cache backend to be used. */ public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityManagerInterface $entity_manager, CacheBackendInterface $cache, LanguageManagerInterface $language_manager, CacheBackendInterface $static_cache = NULL) { + // @todo Remove this line in Drupal 9.0.x and make $static_cache required. $static_cache = isset($static_cache) ? $static_cache : \Drupal::service('entity.static_cache'); parent::__construct($entity_type, $entity_manager, $cache, $static_cache); $this->database = $database;