Commit 234ed4f8 authored by catch's avatar catch

Issue #2226267 by yched: Improve default value handling of fields to be consistent (follow-up).

parent 2a4c2f6b
......@@ -380,7 +380,7 @@ public function isDisplayConfigurable($display_context) {
*/
public function getDefaultValue(ContentEntityInterface $entity) {
// Allow custom default values function.
if (isset($this->definition['default_value_callback'])) {
if (!empty($this->definition['default_value_callback'])) {
$value = call_user_func($this->definition['default_value_callback'], $entity, $this);
}
else {
......@@ -396,9 +396,10 @@ public function getDefaultValue(ContentEntityInterface $entity) {
*
* If set, the callback overrides any set default value.
*
* @param string|array $callback
* The callback to invoke for getting the default value. The callback will
* be invoked with the following arguments:
* @param callable|null $callback
* The callback to invoke for getting the default value (pass NULL to unset
* a previously set callback). The callback will be invoked with the
* following arguments:
* - \Drupal\Core\Entity\ContentEntityInterface $entity
* The entity being created.
* - \Drupal\Core\Field\FieldDefinitionInterface $definition
......
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