public function CacheFragmentController::createCacheFragments in RESTful 7.2
Creates all the caches tags from the tag collection.
Parameters
ArrayCollection $cache_fragments: The collection of tags.
Return value
CacheFragment[] An array of fragments.
File
- src/
RenderCache/ Entity/ CacheFragmentController.php, line 48 - Contains \Drupal\restful\RenderCache\Entity\CacheFragmentController.
Class
- CacheFragmentController
- Class CacheFragmentController.
Namespace
Drupal\restful\RenderCache\EntityCode
public function createCacheFragments(ArrayCollection $cache_fragments) {
$hash = $this
->generateCacheHash($cache_fragments);
if ($fragments = $this
->existingFragments($hash)) {
return $fragments;
}
foreach ($cache_fragments as $tag_type => $tag_value) {
$cache_fragment = new CacheFragment(array(
'value' => $tag_value,
'type' => $tag_type,
'hash' => $hash,
), static::ENTITY_TYPE);
try {
if ($id = $this
->save($cache_fragment)) {
$fragments[] = $cache_fragment;
}
} catch (\Exception $e) {
// Log the exception. It's probably a duplicate fragment.
watchdog_exception('restful', $e);
}
}
return $fragments;
}