Skip to content

Commit

Permalink
Schedule form: Limit maxPlaysPerHour
Browse files Browse the repository at this point in the history
  • Loading branch information
maurofmferrao committed Dec 19, 2024
1 parent 20737a6 commit 766bd4c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/Entity/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,10 @@ public function validate()
if ($this->isPriority < 0) {
throw new InvalidArgumentException(__('Priority must be 0 or a positive number'), 'isPriority');
}
// Check max plays per hour is positive
if ($this->maxPlaysPerHour < 0) {
throw new InvalidArgumentException(__('Maximum plays per hour must be 0 or a positive number'), 'maxPlaysPerHour');
}

// Run some additional validation if we have a recurrence type set.
if (!empty($this->recurrenceType)) {
Expand Down
2 changes: 1 addition & 1 deletion views/schedule-form-add.twig
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@

{% set title %}{% trans "Maximum plays per hour" %}{% endset %}
{% set helpText %}{% trans "Limit the number of times this event will play per hour on each display. For unlimited plays set to 0." %}{{ forms.playerCompat("R308", "", "", "", "R306", "") }}{% endset %}
{{ forms.number("maxPlaysPerHour", title, 0, helpText, 'max-plays-control') }}
{{ forms.number("maxPlaysPerHour", title, 0, helpText, 'max-plays-control', "", "", "", "0") }}

{% set title %}{% trans "Run at CMS Time?" %}{% endset %}
{% set helpText %}{% trans "When selected, your event will run according to the timezone set on the CMS, otherwise the event will run at Display local time" %}{% endset %}
Expand Down
2 changes: 1 addition & 1 deletion views/schedule-form-edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@

{% set title %}{% trans "Maximum plays per hour" %}{% endset %}
{% set helpText %}{% trans "Limit the number of times this event will play per hour on each display. For unlimited plays set to 0." %}{{ forms.playerCompat("R308", "", "", "", "R306", "") }}{% endset %}
{{ forms.number("maxPlaysPerHour", title, event.maxPlaysPerHour, helpText, 'max-plays-control') }}
{{ forms.number("maxPlaysPerHour", title, event.maxPlaysPerHour, helpText, 'max-plays-control', "", "", "", "0") }}

{% set title %}{% trans "Run at CMS Time?" %}{% endset %}
{% set helpText %}{% trans "When selected, your event will run according to the timezone set on the CMS, otherwise the event will run at Display local time" %}{% endset %}
Expand Down

0 comments on commit 766bd4c

Please sign in to comment.