Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oh
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
project
oh
Commits
8580192d
There was an error fetching the commit references. Please try again later.
Commit
8580192d
authored
5 years ago
by
dpi
Browse files
Options
Downloads
Patches
Plain Diff
Added ability for occurrences to specify how they interact with regular hours.
parent
38154e7c
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/OhOccurrence.php
+43
-0
43 additions, 0 deletions
src/OhOccurrence.php
src/OhOpeningHours.php
+3
-0
3 additions, 0 deletions
src/OhOpeningHours.php
with
46 additions
and
0 deletions
src/OhOccurrence.php
+
43
−
0
View file @
8580192d
...
...
@@ -12,6 +12,16 @@ class OhOccurrence extends OhDateRange implements RefinableCacheableDependencyIn
use
RefinableCacheableDependencyTrait
;
/**
* Informs regular hours for the same day should be voided.
*/
public
const
REGULAR_HOUR_INTERACTION_VOID_REGULAR
=
0b1
;
/**
* Informs this occurrence will not trigger regular hours to be voided.
*/
public
const
REGULAR_HOUR_INTERACTION_NO_VOID_REGULAR
=
0b0
;
/**
* Message to add to the occurrence.
*
...
...
@@ -26,6 +36,13 @@ class OhOccurrence extends OhDateRange implements RefinableCacheableDependencyIn
*/
protected
$open
=
FALSE
;
/**
* Regular hours interaction behaviour.
*
* @var int
*/
protected
$regularHourInteraction
=
self
::
REGULAR_HOUR_INTERACTION_NO_VOID_REGULAR
;
/**
* Add a message for the occurrence.
*
...
...
@@ -88,6 +105,32 @@ class OhOccurrence extends OhDateRange implements RefinableCacheableDependencyIn
return
$this
->
open
;
}
/**
* Sets interaction behaviour with regular hours.
*
* Note: it only takes one exception to trigger voiding.
*
* @param int $value
* Interaction constant. See static::REGULAR_HOUR_INTERACTION_*.
*
* @return $this
* Return object for chaining.
*/
public
function
setRegularHourInteraction
(
int
$value
=
self
::
REGULAR_HOUR_INTERACTION_NO_VOID_REGULAR
)
{
$this
->
regularHourInteraction
=
$value
;
return
$this
;
}
/**
* Get interaction behaviour with regular hours.
*
* This method should only be used by exceptions, not regular hours.
*
* @return mixed
* Interaction constant. See static::REGULAR_HOUR_INTERACTION_*.
*/
public
function
getRegularHourInteraction
():
int
{
return
$this
->
regularHourInteraction
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/OhOpeningHours.php
+
3
−
0
View file @
8580192d
...
...
@@ -54,6 +54,9 @@ class OhOpeningHours implements OhOpeningHoursInterface {
if
(
$exceptions
)
{
foreach
(
$exceptions
as
$exception
)
{
$dayKey
=
$exception
->
getStart
()
->
format
(
static
::
DAY_FORMAT
);
if
(
!
$exception
->
getRegularHourInteraction
()
&
OhOccurrence
::
REGULAR_HOUR_INTERACTION_VOID_REGULAR
)
{
continue
;
}
// Remove any regular hour occurrences on the same day as exceptions.
$occurrences
=
array_filter
(
$occurrences
,
function
(
OhOccurrence
$occurrence
)
use
(
$dayKey
)
{
...
...
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