class SocialFilePrivateFieldsConfigOverride in Open Social 8.7
Same name and namespace in other branches
- 8.9 modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 8 modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 8.2 modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 8.3 modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 8.4 modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 8.5 modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 8.6 modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 8.8 modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 10.3.x modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 10.0.x modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 10.1.x modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
- 10.2.x modules/custom/social_file_private/src/SocialFilePrivateFieldsConfigOverride.php \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
Class SocialFilePrivateFieldsConfigOverride.
Override the field.storage configuration and set private uri_scheme.
@package Drupal\social_file_private
Hierarchy
- class \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride implements ConfigFactoryOverrideInterface
Expanded class hierarchy of SocialFilePrivateFieldsConfigOverride
2 string references to 'SocialFilePrivateFieldsConfigOverride'
- SocialFilePrivateFieldsConfigOverride::getCacheSuffix in modules/
custom/ social_file_private/ src/ SocialFilePrivateFieldsConfigOverride.php - The string to append to the configuration static cache name.
- social_file_private.services.yml in modules/
custom/ social_file_private/ social_file_private.services.yml - modules/custom/social_file_private/social_file_private.services.yml
1 service uses SocialFilePrivateFieldsConfigOverride
- social_file_private_fields.overrider in modules/
custom/ social_file_private/ social_file_private.services.yml - \Drupal\social_file_private\SocialFilePrivateFieldsConfigOverride
File
- modules/
custom/ social_file_private/ src/ SocialFilePrivateFieldsConfigOverride.php, line 17
Namespace
Drupal\social_file_privateView source
class SocialFilePrivateFieldsConfigOverride implements ConfigFactoryOverrideInterface {
/**
* Get all the file and image fields to protect.
*
* @TODO Retrieve the file and image fields programmatically.
*
* Note: this list is now fixed, but an error will be shown in the status
* report when there are fields of type image, file using public uri_scheme.
*
* @return array
* Returns an array containing config_names.
*/
public function getFileImageFieldsToProtect() {
// We want to override all the known file and image uploads.
$config_names = [
'field.storage.block_content.field_hero_image',
'field.storage.comment.field_comment_files',
'field.storage.group.field_group_image',
'field.storage.node.field_book_image',
'field.storage.node.field_event_image',
'field.storage.node.field_files',
'field.storage.node.field_page_image',
'field.storage.node.field_topic_image',
'field.storage.post.field_post_image',
'field.storage.profile.field_profile_image',
'field.storage.profile.field_profile_banner_image',
'field.storage.paragraph.field_hero_image',
'field.storage.paragraph.field_hero_small_image',
];
return $config_names;
}
/**
* {@inheritdoc}
*/
public function loadOverrides($names) {
$overrides = [];
if (PrivateStream::basePath()) {
$config_names = $this
->getFileImageFieldsToProtect();
foreach ($config_names as $config_name) {
if (in_array($config_name, $names)) {
$config = \Drupal::service('config.factory')
->getEditable($config_name);
$uri_scheme = $config
->get('settings.uri_scheme');
if ($uri_scheme == 'public') {
$overrides[$config_name]['settings']['uri_scheme'] = 'private';
}
}
}
}
return $overrides;
}
/**
* {@inheritdoc}
*/
public function getCacheSuffix() {
return 'SocialFilePrivateFieldsConfigOverride';
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata($name) {
return new CacheableMetadata();
}
/**
* {@inheritdoc}
*/
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SocialFilePrivateFieldsConfigOverride:: |
public | function |
Creates a configuration object for use during install and synchronization. Overrides ConfigFactoryOverrideInterface:: |
|
SocialFilePrivateFieldsConfigOverride:: |
public | function |
Gets the cacheability metadata associated with the config factory override. Overrides ConfigFactoryOverrideInterface:: |
|
SocialFilePrivateFieldsConfigOverride:: |
public | function |
The string to append to the configuration static cache name. Overrides ConfigFactoryOverrideInterface:: |
|
SocialFilePrivateFieldsConfigOverride:: |
public | function | Get all the file and image fields to protect. | |
SocialFilePrivateFieldsConfigOverride:: |
public | function |
Returns config overrides. Overrides ConfigFactoryOverrideInterface:: |