public function BlazyDependenciesTrait::onDependencyRemoval in Blazy 8.2
File
- src/
Dejavu/ BlazyDependenciesTrait.php, line 49
Class
- BlazyDependenciesTrait
- A Trait common for file, image or media to handle dependencies.
Namespace
Drupal\blazy\DejavuCode
public function onDependencyRemoval(array $dependencies) {
$changed = parent::onDependencyRemoval($dependencies);
$style_ids = [];
foreach ([
'box',
'box_media',
'image',
'thumbnail',
] as $key) {
if (!empty($this
->getSetting($key . '_style'))) {
$style_ids[] = $this
->getSetting($key . '_style');
}
}
/** @var \Drupal\image\ImageStyleInterface $style */
foreach ($style_ids as $name => $style_id) {
if ($style_id && ($style = $this->formatter
->entityLoad($style_id, 'image_style'))) {
if (!empty($dependencies[$style
->getConfigDependencyKey()][$style
->getConfigDependencyName()])) {
$replacement_id = $this->formatter
->getEntityTypeManager()
->getStorage('image_style')
->getReplacementId($style_id);
// If a valid replacement has been provided in the storage, replace
// the image style with the replacement and signal that the formatter
// plugin settings were updated.
if ($replacement_id && $this->formatter
->entityLoad($replacement_id, 'image_style')) {
$this
->setSetting($name, $replacement_id);
$changed = TRUE;
}
}
}
}
return $changed;
}