public function renderFullCached($cacheKey, $view, $data = null, $lifeTime = null, $force = false)
{
$cache = $this->cacher->getDistributedCache($cacheKey);
$mTime = $this->getViewMTime($view);
if (!is_string($cache)) {
$cache = null;
} else {
$cache = @unserialize($cache);
}
if ($force || !$cache || !$cache['content'] || !is_array($cache) || $mTime != $cache['fileMTime']) {
$oldResponse = clone $this->pageStack->getPageResponse();
$data2 = $data;
if (is_callable($data)) {
$data2 = call_user_func($data, $view);
if (null === $data2) {
//the data callback returned NULL so this means
//we aren't the correct controller for this request
//or the request contains invalid input
return null;
}
}
$content = $this->templating->render($view, $data2);
$response = $this->pageStack->getPageResponse();
$diff = $oldResponse->diff($response);
$cache = array('content' => $content, 'fileMTime' => $mTime, 'responseDiff' => $diff);
$this->cacher->setDistributedCache($cacheKey, serialize($cache), $lifeTime ?: 3600);
} else {
if ($cache['responseDiff']) {
$this->pageStack->getPageResponse()->patch($cache['responseDiff']);
}
}
return $this->pageResponseFactory->createPluginResponse($cache['content']);
}