Problem/Motivation
Context definitions need a way to provide default values. Example:
<?php
/**
* context = {
* "text" = @ContextDefinition("string", label = @Translation("Text"), default_value = "replace me!")
* }
*/
?>
Proposed resolution
Add getDefaultValue() and setDefaultValue() methods to ContextDefinitionInterface. This is an expected change to the interface and has also been documented in code pointing to #2346999: Make ContextDefinitionInterface more expressible.
Remaining tasks
Review the patch.
User interface changes
None.
API changes
ContextDefinitionInterface changes, but all parties are aware of that and this is documented.
Original report by @Xano
\Drupal\Core\TypedData\TypedData::applyDefaultValue()
now sets NULL as its own default value, while we can easily let definitions define the default value. I *think* this used to work, but I'm not sure.
I'm adding this as sub-issue to #2346999: Make ContextDefinitionInterface more expressible.