public function PluginSettingsBase::onDependencyRemoval in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Field/PluginSettingsBase.php \Drupal\Core\Field\PluginSettingsBase::onDependencyRemoval()
- 10 core/lib/Drupal/Core/Field/PluginSettingsBase.php \Drupal\Core\Field\PluginSettingsBase::onDependencyRemoval()
Informs the plugin that some configuration it depends on will be deleted.
This method allows plugins to keep their configuration up-to-date when a dependency calculated with ::calculateDependencies() is removed. For example, an entity view display contains a formatter having a setting pointing to an arbitrary config entity. When that config entity is deleted, this method is called by the view display to react to the dependency removal by updating its configuration.
This method must return TRUE if the removal event updated the plugin configuration or FALSE otherwise.
Parameters
array $dependencies: An array of dependencies that will be deleted keyed by dependency type. Dependency types are 'config', 'content', 'module' and 'theme'.
Return value
bool TRUE if the plugin configuration has changed, FALSE if not.
Overrides PluginSettingsInterface::onDependencyRemoval
See also
\Drupal\Core\Entity\EntityDisplayBase
3 calls to PluginSettingsBase::onDependencyRemoval()
- ImageFormatter::onDependencyRemoval in core/
modules/ image/ src/ Plugin/ Field/ FieldFormatter/ ImageFormatter.php - Informs the plugin that some configuration it depends on will be deleted.
- ImageWidget::onDependencyRemoval in core/
modules/ image/ src/ Plugin/ Field/ FieldWidget/ ImageWidget.php - Informs the plugin that some configuration it depends on will be deleted.
- TestFieldWidget::onDependencyRemoval in core/
modules/ field/ tests/ modules/ field_test/ src/ Plugin/ Field/ FieldWidget/ TestFieldWidget.php - Informs the plugin that some configuration it depends on will be deleted.
3 methods override PluginSettingsBase::onDependencyRemoval()
- ImageFormatter::onDependencyRemoval in core/
modules/ image/ src/ Plugin/ Field/ FieldFormatter/ ImageFormatter.php - Informs the plugin that some configuration it depends on will be deleted.
- ImageWidget::onDependencyRemoval in core/
modules/ image/ src/ Plugin/ Field/ FieldWidget/ ImageWidget.php - Informs the plugin that some configuration it depends on will be deleted.
- TestFieldWidget::onDependencyRemoval in core/
modules/ field/ tests/ modules/ field_test/ src/ Plugin/ Field/ FieldWidget/ TestFieldWidget.php - Informs the plugin that some configuration it depends on will be deleted.
File
- core/
lib/ Drupal/ Core/ Field/ PluginSettingsBase.php, line 153
Class
- PluginSettingsBase
- Base class for the Field API plugins.
Namespace
Drupal\Core\FieldCode
public function onDependencyRemoval(array $dependencies) {
$changed = FALSE;
if (!empty($this->thirdPartySettings) && !empty($dependencies['module'])) {
$old_count = count($this->thirdPartySettings);
$this->thirdPartySettings = array_diff_key($this->thirdPartySettings, array_flip($dependencies['module']));
$changed = $old_count != count($this->thirdPartySettings);
}
return $changed;
}