Skip to content
Snippets Groups Projects
Commit af8fc7c8 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2580319 by Arla: Field configs should adjust third party settings when...

Issue #2580319 by Arla: Field configs should adjust third party settings when dependencies are removed
parent e900ded4
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -251,9 +251,12 @@ public function calculateDependencies() {
* {@inheritdoc}
*/
public function onDependencyRemoval(array $dependencies) {
$changed = parent::onDependencyRemoval($dependencies);
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
$definition = $field_type_manager->getDefinition($this->getType());
$changed = $definition['class']::onDependencyRemoval($this, $dependencies);
if ($definition['class']::onDependencyRemoval($this, $dependencies)) {
$changed = TRUE;
}
return $changed;
}
......
......@@ -212,6 +212,35 @@ public function testCalculateDependenciesIncorrectBundle() {
$field->calculateDependencies();
}
/**
* @covers ::onDependencyRemoval
*/
public function testOnDependencyRemoval() {
$this->fieldTypePluginManager->expects($this->any())
->method('getDefinition')
->with('test_field')
->willReturn(['class' => '\Drupal\Tests\field\Unit\DependencyFieldItem']);
$field = new FieldConfig([
'field_name' => $this->fieldStorage->getName(),
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle',
'field_type' => 'test_field',
'dependencies' => [
'module' => [
'fruiter',
]
],
'third_party_settings' => [
'fruiter' => [
'fruit' => 'apple',
]
]
]);
$changed = $field->onDependencyRemoval(['module' => ['fruiter']]);
$this->assertTrue($changed);
}
/**
* @covers ::toArray
*/
......@@ -290,4 +319,7 @@ public static function calculateDependencies(FieldDefinitionInterface $definitio
return ['module' => ['test_module3']];
}
public static function onDependencyRemoval($field_config, $dependencies) {
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment