function FileParsingCacheCollectorBase::resolveCacheMiss
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Utility/FileParsingCacheCollectorBase.php \Drupal\Core\Utility\FileParsingCacheCollectorBase::resolveCacheMiss()
Resolves a cache miss.
When an offset is not found in the object, this is treated as a cache miss. This method allows classes using this implementation to look up the actual value and allow it to be cached.
Parameters
string $key: The offset that was requested.
Return value
mixed The value of the offset, or NULL if no value was found.
Overrides CacheCollector::resolveCacheMiss
1 call to FileParsingCacheCollectorBase::resolveCacheMiss()
- FileParsingCacheCollectorBase::get in core/
lib/ Drupal/ Core/ Utility/ FileParsingCacheCollectorBase.php - Gets value from the cache.
File
-
core/
lib/ Drupal/ Core/ Utility/ FileParsingCacheCollectorBase.php, line 43
Class
- FileParsingCacheCollectorBase
- Caches file parsing in a cache collector.
Namespace
Drupal\Core\UtilityCode
public function resolveCacheMiss($key) : array {
if (file_exists($key)) {
$mtime = filemtime($key);
$this->storage[$key] = [
'mtime' => $mtime,
'parsed' => $this->parseFile(file_get_contents($key)) ?? [],
];
$this->persist($key);
return $this->storage[$key]['parsed'];
}
if (isset($this->storage[$key])) {
$this->delete($key);
}
return [];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.