Commit af8fc7c8 authored by alexpott's avatar alexpott

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
......@@ -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) {
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment