Same name in other branches
- 8.x-1.x src/Plugin/Field/FieldFormatter/ColorboxFormatter.php \Drupal\colorbox\Plugin\Field\FieldFormatter\ColorboxFormatter::onDependencyRemoval()
File
-
src/
Plugin/ Field/ FieldFormatter/ ColorboxFormatter.php, line 475
Class
- ColorboxFormatter
- Plugin implementation of the 'colorbox' formatter.
Namespace
Drupal\colorbox\Plugin\Field\FieldFormatterCode
public function onDependencyRemoval(array $dependencies) {
$changed = parent::onDependencyRemoval($dependencies);
$style_ids = [];
$style_ids['colorbox_node_style'] = $this->getSetting('colorbox_node_style');
if (!empty($this->getSetting('colorbox_node_style_first'))) {
$style_ids['colorbox_node_style_first'] = $this->getSetting('colorbox_node_style_first');
}
$style_ids['colorbox_image_style'] = $this->getSetting('colorbox_image_style');
foreach ($style_ids as $name => $style_id) {
/** @var \Drupal\image\ImageStyleInterface $style */
if ($style_id && ($style = ImageStyle::load($style_id))) {
if (!empty($dependencies[$style->getConfigDependencyKey()][$style->getConfigDependencyName()])) {
$replacement_id = $this->imageStyleStorage
->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 && ImageStyle::load($replacement_id)) {
$this->setSetting($name, $replacement_id);
$changed = TRUE;
}
}
}
}
return $changed;
}