protected function FileMetadataPluginBase::isUriFileMetadataCacheable in File metadata manager 8
Same name and namespace in other branches
- 8.2 src/Plugin/FileMetadata/FileMetadataPluginBase.php \Drupal\file_mdm\Plugin\FileMetadata\FileMetadataPluginBase::isUriFileMetadataCacheable()
Checks if file metadata should be cached.
Return value
array|bool The caching settings array retrieved from configuration if file metadata is cacheable, FALSE otherwise.
3 calls to FileMetadataPluginBase::isUriFileMetadataCacheable()
- FileMetadataPluginBase::deleteCachedMetadata in src/
Plugin/ FileMetadata/ FileMetadataPluginBase.php - Removes cached metadata for file at URI.
- FileMetadataPluginBase::loadMetadataFromCache in src/
Plugin/ FileMetadata/ FileMetadataPluginBase.php - Loads file metadata from a cache entry.
- FileMetadataPluginBase::saveMetadataToCache in src/
Plugin/ FileMetadata/ FileMetadataPluginBase.php - Caches metadata for file at URI.
File
- src/
Plugin/ FileMetadata/ FileMetadataPluginBase.php, line 327
Class
- FileMetadataPluginBase
- Abstract implementation of a base File Metadata plugin.
Namespace
Drupal\file_mdm\Plugin\FileMetadataCode
protected function isUriFileMetadataCacheable() {
// Check plugin settings first, if they override general settings.
if ($this->configuration['cache']['override']) {
$settings = $this->configuration['cache']['settings'];
if (!$settings['enabled']) {
return FALSE;
}
}
// Use general settings if they are not overridden by plugin.
if (!isset($settings)) {
$settings = $this->configFactory
->get('file_mdm.settings')
->get('metadata_cache');
if (!$settings['enabled']) {
return FALSE;
}
}
// URIs without valid scheme, and temporary:// URIs are not cached.
if (!file_valid_uri($this
->getUri()) || file_uri_scheme($this
->getUri()) === 'temporary') {
return FALSE;
}
// URIs falling into disallowed paths are not cached.
foreach ($settings['disallowed_paths'] as $pattern) {
$p = "#^" . strtr(preg_quote($pattern, '#'), [
'\\*' => '.*',
'\\?' => '.',
]) . "\$#i";
if (preg_match($p, $this
->getUri())) {
return FALSE;
}
}
return $settings;
}