Skip to content
Snippets Groups Projects
Commit 48a83d00 authored by Eelke Blok's avatar Eelke Blok
Browse files

Early exit when the value is an array

parent 2fa667c1
No related branches found
No related tags found
No related merge requests found
Pipeline #339752 passed
Pipeline: drupal-3313231

#339757

    ......@@ -45,13 +45,19 @@ public function getValue() {
    /** @var \Drupal\Core\Field\FieldItemInterface $item */
    $item = $this->getParent();
    $value = $item->{($this->definition->getSetting('date source'))};
    $value = is_array($value) ? array_shift($value) : $value;
    // A date cannot be created from a NULL value.
    if ($value === NULL) {
    return NULL;
    }
    // When the field is empty, the returned value will be an array with empty
    // values. Treat it as an empty value. Valid values will return a formatted
    // string.
    if (is_array($value)) {
    return NULL;
    }
    $datetime_type = $item->getFieldDefinition()->getSetting('datetime_type');
    $storage_format = $datetime_type === DateTimeItem::DATETIME_TYPE_DATE ? DateTimeItemInterface::DATE_STORAGE_FORMAT : DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
    try {
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment