Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
smart_date-3436045
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
smart_date-3436045
Commits
0712a01d
Commit
0712a01d
authored
3 years ago
by
Martin Anderson-Clutz
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3229093
by mandclu: Add Date Augmenter support in the Daily Range formatter
parent
ed71c322
No related branches found
Branches containing commit
Tags
8.x-1.21
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateDailyRangeFormatter.php
+36
-0
36 additions, 0 deletions
...gin/Field/FieldFormatter/SmartDateDailyRangeFormatter.php
with
36 additions
and
0 deletions
modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateDailyRangeFormatter.php
+
36
−
0
View file @
0712a01d
...
...
@@ -2,6 +2,7 @@
namespace
Drupal\smart_date_recur\Plugin\Field\FieldFormatter
;
use
Drupal\Core\Datetime\DrupalDateTime
;
use
Drupal\Core\Field\FieldItemListInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\smart_date
\Entity\SmartDateFormat
;
...
...
@@ -75,6 +76,18 @@ class SmartDateDailyRangeFormatter extends SmartDateDefaultFormatter {
$time_wrapper
=
$this
->
getSetting
(
'time_wrapper'
);
$rrules
=
[];
$rrules_nondaily
=
[];
// Look for the Date Augmenter plugin manager service.
$augmenters
=
[];
if
(
!
empty
(
\Drupal
::
hasService
(
'plugin.manager.dateaugmenter'
)))
{
$dateAugmenterManager
=
\Drupal
::
service
(
'plugin.manager.dateaugmenter'
);
// TODO: Support custom entities.
$config
=
$this
->
getThirdPartySettings
(
'date_augmenter'
);
$active_augmenters
=
$config
[
'status'
]
??
[];
$augmenters
=
$dateAugmenterManager
->
getActivePlugins
(
$active_augmenters
);
$entity
=
$items
->
getEntity
();
}
foreach
(
$items
as
$delta
=>
$item
)
{
$timezone
=
$item
->
timezone
?
$item
->
timezone
:
NULL
;
if
(
empty
(
$item
->
value
)
||
empty
(
$item
->
end_value
))
{
...
...
@@ -131,6 +144,29 @@ class SmartDateDailyRangeFormatter extends SmartDateDefaultFormatter {
if
(
$time_wrapper
)
{
$this
->
addTimeWrapper
(
$elements
[
$delta
],
$item
->
value
,
$item
->
end_value
,
$timezone
);
}
if
(
$augmenters
)
{
foreach
(
$augmenters
as
$augmenter_id
=>
$augmenter
)
{
// Use the enabled plugin to manipulate the output.
$augmenter
->
augmentOutput
(
// The existing render array.
$elements
[
$delta
],
// The start and end (optional), as DrupalDateTime objects.
DrupalDateTime
::
createFromTimestamp
(
$item
->
value
),
DrupalDateTime
::
createFromTimestamp
(
$item
->
end_value
),
// An optional array of additional parameters.
[
'timezone'
=>
$timezone
,
'allday'
=>
static
::
isAllDay
(
$item
->
value
,
$item
->
end_value
,
$timezone
),
'entity'
=>
$entity
,
'settings'
=>
$config
[
'settings'
][
$augmenter_id
],
'delta'
=>
$delta
,
'formatter'
=>
$this
,
'field_name'
=>
$this
->
fieldDefinition
->
getName
(),
]
);
}
}
}
}
foreach
(
$rrules
as
$rrule_collected
)
{
...
...
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