public function ImageWidget::onDependencyRemoval in Drupal 10
Same name and namespace in other branches
- 8 core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php \Drupal\image\Plugin\Field\FieldWidget\ImageWidget::onDependencyRemoval()
- 9 core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php \Drupal\image\Plugin\Field\FieldWidget\ImageWidget::onDependencyRemoval()
File
- core/
modules/ image/ src/ Plugin/ Field/ FieldWidget/ ImageWidget.php, line 319
Class
- ImageWidget
- Plugin implementation of the 'image_image' widget.
Namespace
Drupal\image\Plugin\Field\FieldWidgetCode
public function onDependencyRemoval(array $dependencies) {
$changed = parent::onDependencyRemoval($dependencies);
$style_id = $this
->getSetting('preview_image_style');
/** @var \Drupal\image\ImageStyleInterface $style */
if ($style_id && ($style = ImageStyle::load($style_id))) {
if (!empty($dependencies[$style
->getConfigDependencyKey()][$style
->getConfigDependencyName()])) {
/** @var \Drupal\image\ImageStyleStorageInterface $storage */
$storage = \Drupal::entityTypeManager()
->getStorage($style
->getEntityTypeId());
$replacement_id = $storage
->getReplacementId($style_id);
// If a valid replacement has been provided in the storage, replace the
// preview image style with the replacement.
if ($replacement_id && ImageStyle::load($replacement_id)) {
$this
->setSetting('preview_image_style', $replacement_id);
}
else {
$this
->setSetting('preview_image_style', '');
}
// Signal that the formatter plugin settings were updated.
$changed = TRUE;
}
}
return $changed;
}