class SocialLazyLoadingTextFormatOverride in Open Social 8.9
Same name and namespace in other branches
- 8.6 modules/custom/social_lazy_loading/src/SocialLazyLoadingTextFormatOverride.php \Drupal\social_lazy_loading\SocialLazyLoadingTextFormatOverride
- 8.7 modules/custom/social_lazy_loading/src/SocialLazyLoadingTextFormatOverride.php \Drupal\social_lazy_loading\SocialLazyLoadingTextFormatOverride
- 8.8 modules/custom/social_lazy_loading/src/SocialLazyLoadingTextFormatOverride.php \Drupal\social_lazy_loading\SocialLazyLoadingTextFormatOverride
- 10.3.x modules/custom/social_lazy_loading/src/SocialLazyLoadingTextFormatOverride.php \Drupal\social_lazy_loading\SocialLazyLoadingTextFormatOverride
- 10.0.x modules/custom/social_lazy_loading/src/SocialLazyLoadingTextFormatOverride.php \Drupal\social_lazy_loading\SocialLazyLoadingTextFormatOverride
- 10.1.x modules/custom/social_lazy_loading/src/SocialLazyLoadingTextFormatOverride.php \Drupal\social_lazy_loading\SocialLazyLoadingTextFormatOverride
- 10.2.x modules/custom/social_lazy_loading/src/SocialLazyLoadingTextFormatOverride.php \Drupal\social_lazy_loading\SocialLazyLoadingTextFormatOverride
Class SocialLazyLoadingTextFormatOverride.
@package Drupal\social_lazy_loading
Hierarchy
- class \Drupal\social_lazy_loading\SocialLazyLoadingTextFormatOverride implements ConfigFactoryOverrideInterface
Expanded class hierarchy of SocialLazyLoadingTextFormatOverride
2 string references to 'SocialLazyLoadingTextFormatOverride'
- SocialLazyLoadingTextFormatOverride::getCacheSuffix in modules/
custom/ social_lazy_loading/ src/ SocialLazyLoadingTextFormatOverride.php - The string to append to the configuration static cache name.
- social_lazy_loading.services.yml in modules/
custom/ social_lazy_loading/ social_lazy_loading.services.yml - modules/custom/social_lazy_loading/social_lazy_loading.services.yml
1 service uses SocialLazyLoadingTextFormatOverride
- social_lazy_loading.overrider in modules/
custom/ social_lazy_loading/ social_lazy_loading.services.yml - Drupal\social_lazy_loading\SocialLazyLoadingTextFormatOverride
File
- modules/
custom/ social_lazy_loading/ src/ SocialLazyLoadingTextFormatOverride.php, line 15
Namespace
Drupal\social_lazy_loadingView source
class SocialLazyLoadingTextFormatOverride implements ConfigFactoryOverrideInterface {
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* Constructs the configuration override.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
/**
* {@inheritdoc}
*/
public function loadOverrides($names) {
$overrides = [];
$formats = [
'basic_html' => TRUE,
'full_html' => TRUE,
'plain_text' => TRUE,
'simple_text' => TRUE,
'restricted_html' => TRUE,
'mail_html' => TRUE,
];
$this->moduleHandler
->alter('social_lazy_loading_formats', $formats);
foreach ($formats as $format => $convert_url) {
if (in_array('filter.format.' . $format, $names, FALSE)) {
$this
->addFilterOverride($format, $convert_url, $overrides);
}
}
// Set lazy loading settings.
if (in_array('lazy.settings', $names, FALSE)) {
$overrides['lazy.settings']['alter_tag'] = [
'img' => 'img',
'iframe' => 'iframe',
];
}
return $overrides;
}
/**
* Alters the filter settings for the text format.
*
* @param string $text_format
* A config name.
* @param bool $convert_url
* TRUE if filter should be used.
* @param array $overrides
* An override configuration.
*/
protected function addFilterOverride($text_format, $convert_url, array &$overrides) {
$config_name = 'filter.format.' . $text_format;
if ($convert_url) {
$overrides[$config_name]['dependencies']['module']['lazy'] = 'lazy';
$overrides[$config_name]['filters']['lazy_filter'] = [
'id' => 'lazy_filter',
'provider' => 'lazy',
'status' => TRUE,
'weight' => 999,
'settings' => [],
];
}
}
/**
* {@inheritdoc}
*/
public function getCacheableMetadata($name) {
return new CacheableMetadata();
}
/**
* {@inheritdoc}
*/
public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
return NULL;
}
/**
* {@inheritdoc}
*/
public function getCacheSuffix() {
return 'SocialLazyLoadingTextFormatOverride';
}
}