public function get($entryIdentifier)
{
if (!$this->isValidEntryIdentifier($entryIdentifier)) {
throw new \InvalidArgumentException('"' . $entryIdentifier . '" is not a valid cache entry identifier.', 1233057752);
}
$code = $this->backend->get($entryIdentifier);
if ($code === false) {
return false;
}
preg_match('/^(?:.*\\n){1}((?:.*\\n)*)(?:.+\\n?|\\n)$/', $code, $matches);
return $matches[1];
}
/** * Shutdown the Evaluator */ public function shutdownObject() { if (count($this->newExpressions) > 0) { $changesToPersist = false; $codeToBeCached = $this->expressionCache->get('cachedExpressionClosures'); /** * At this point a race condition could happen, that we try to prevent with an additional check. * So we compare the evaluated expressions during this request with the methods the cache has at * this point and only add methods that are not present. Only if we added anything we write the cache. */ foreach ($this->newExpressions as $functionName => $newExpression) { if (strpos($codeToBeCached, $functionName) === false) { $codeToBeCached .= 'if (!function_exists(\'' . $functionName . '\')) { ' . $newExpression . ' }' . chr(10); $changesToPersist = true; } } if ($changesToPersist) { $this->expressionCache->set('cachedExpressionClosures', $codeToBeCached); } } }