Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3313231
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3313231
Commits
48a83d00
Commit
48a83d00
authored
6 months ago
by
Eelke Blok
Browse files
Options
Downloads
Patches
Plain Diff
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
6 months ago
Stage: 🪄 Lint
Stage: 🗜️ Test
Pipeline: drupal-3313231
#339757
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/datetime/src/DateTimeComputed.php
+7
-1
7 additions, 1 deletion
core/modules/datetime/src/DateTimeComputed.php
with
7 additions
and
1 deletion
core/modules/datetime/src/DateTimeComputed.php
+
7
−
1
View file @
48a83d00
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment