- * Gets entities from the static cache.
- *
- * @param array $ids
- * If not empty, return entities that match these IDs.
- *
- * @return \Drupal\Core\Entity\EntityInterface[]
- * Array of entities from the entity cache.
- */
- protected function getFromStaticCache(array $ids) {
- $entities = [];
- // Load any available entities from the internal cache.
- if ($this->entityType->isStaticallyCacheable() && !empty($this->entities)) {
- $config_overrides_key = $this->overrideFree ? '' : implode(':', $this->configFactory->getCacheKeys());
- foreach ($ids as $id) {
- if (!empty($this->entities[$id])) {
- if (isset($this->entities[$id][$config_overrides_key])) {
- $entities[$id] = $this->entities[$id][$config_overrides_key];
- }
- }
- }
- }
- return $entities;
- }
-
- /**
- * Stores entities in the static entity cache.
- *
- * @param \Drupal\Core\Entity\EntityInterface[] $entities
- * Entities to store in the cache.
- */
- protected function setStaticCache(array $entities) {
- if ($this->entityType->isStaticallyCacheable()) {
- $config_overrides_key = $this->overrideFree ? '' : implode(':', $this->configFactory->getCacheKeys());
- foreach ($entities as $id => $entity) {
- $this->entities[$id][$config_overrides_key] = $entity;
- }
- }