Issue #2580319 by Arla: Field configs should adjust third party settings when dependencies are removed
parent
e900ded48f
commit
af8fc7c8c7
|
@ -251,9 +251,12 @@ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigIn
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function onDependencyRemoval(array $dependencies) {
|
public function onDependencyRemoval(array $dependencies) {
|
||||||
|
$changed = parent::onDependencyRemoval($dependencies);
|
||||||
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
|
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
|
||||||
$definition = $field_type_manager->getDefinition($this->getType());
|
$definition = $field_type_manager->getDefinition($this->getType());
|
||||||
$changed = $definition['class']::onDependencyRemoval($this, $dependencies);
|
if ($definition['class']::onDependencyRemoval($this, $dependencies)) {
|
||||||
|
$changed = TRUE;
|
||||||
|
}
|
||||||
return $changed;
|
return $changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,6 +212,35 @@ class FieldConfigEntityUnitTest extends UnitTestCase {
|
||||||
$field->calculateDependencies();
|
$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
|
* @covers ::toArray
|
||||||
*/
|
*/
|
||||||
|
@ -290,4 +319,7 @@ class DependencyFieldItem {
|
||||||
return ['module' => ['test_module3']];
|
return ['module' => ['test_module3']];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function onDependencyRemoval($field_config, $dependencies) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue