You are here

protected function CachePluginBase::prepareViewResult in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/cache/CachePluginBase.php \Drupal\views\Plugin\views\cache\CachePluginBase::prepareViewResult()
  2. 10 core/modules/views/src/Plugin/views/cache/CachePluginBase.php \Drupal\views\Plugin\views\cache\CachePluginBase::prepareViewResult()

Prepares the view result before putting it into cache.

Parameters

\Drupal\views\ResultRow[] $result: The result containing loaded entities.

Return value

\Drupal\views\ResultRow[] The result without loaded entities.

1 call to CachePluginBase::prepareViewResult()
CachePluginBase::cacheSet in core/modules/views/src/Plugin/views/cache/CachePluginBase.php
Save data to the cache.

File

core/modules/views/src/Plugin/views/cache/CachePluginBase.php, line 283

Class

CachePluginBase
The base plugin to handle caching.

Namespace

Drupal\views\Plugin\views\cache

Code

protected function prepareViewResult(array $result) {
  $return = [];

  // Clone each row object and remove any loaded entities, to keep the
  // original result rows intact.
  foreach ($result as $key => $row) {
    $clone = clone $row;
    $clone
      ->resetEntityData();
    $return[$key] = $clone;
  }
  return $return;
}