Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_ct_service
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_ct_service
Commits
ac15ba6c
Commit
ac15ba6c
authored
1 year ago
by
Eric Bremner
Browse files
Options
Downloads
Patches
Plain Diff
ISTWCMS-5551: updating the update hook to include adding closed to comments for exception days
parent
64fd166b
No related branches found
No related tags found
2 merge requests
!60
ISTWCMS-6095 Update maxlength settings for title, text fields and link fields...
,
!33
ISTWCMS-5551 update office hours
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uw_ct_service.install
+43
-0
43 additions, 0 deletions
uw_ct_service.install
with
43 additions
and
0 deletions
uw_ct_service.install
+
43
−
0
View file @
ac15ba6c
...
...
@@ -10,10 +10,53 @@
*/
function
uw_ct_service_update_9101
(
&
$sandbox
)
{
// Uninstall the office hours exceptions module.
\Drupal
::
service
(
'module_installer'
)
->
uninstall
([
'office_hours_exceptions'
]);
// Unset the core extension, so that we remove the warning
// about this module still being enabled.
\Drupal
::
configFactory
()
->
getEditable
(
'core.extension'
)
->
clear
(
'module.office_hours_exceptions'
)
->
save
(
TRUE
);
// Get all the service nodes.
$services
=
\Drupal
::
entityTypeManager
()
->
getStorage
(
'node'
)
->
loadByProperties
([
'type'
=>
'uw_ct_service'
]);
// Step through all service nodes and add the Closed
// to the exception days if an all day service.
foreach
(
$services
as
$service
)
{
// Get the hours field.
$hours
=
$service
->
field_uw_service_hours
->
getValue
();
// If there are hours, check if we have to add closed
// to the exception days.
if
(
$hours
)
{
// Step through each of the hours and check exception
// days and see if we have to add closed.
foreach
(
$hours
as
$index
=>
$hour
)
{
// If this an exception day (day > 6) and it is an
// all day service (start and end hours -1), then
// add Closed to the comments.
if
(
$hour
[
'day'
]
>
6
&&
$hour
[
'starthours'
]
==
'-1'
&&
$hour
[
'endhours'
]
==
'-1'
)
{
// Add closed to the comments.
$hours
[
$index
][
'comment'
]
=
'Closed'
;
}
}
// Set the service hours and save the node.
$service
->
set
(
'field_uw_service_hours'
,
$hours
);
$service
->
save
();
}
}
}
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