Search by

xddesigners / silverstripe-openinghours

RVXD

Manage opening hours (with exceptions) for any DataObject in SilverStripe, backed by spatie/opening-hours.

Package info

github.com/xddesigners/silverstripe-openinghours

Type:silverstripe-vendormodule

pkg:composer/xddesigners/silverstripe-openinghours

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-09-11 17:40 UTC

This package is auto-updated.

Last update: 2026-09-12 11:46:41 UTC


README

Manage opening hours (with exceptions) for any DataObject in SilverStripe, backed by spatie/opening-hours.

SilverStripe 6 module. Extracted from the in-house Linberg (viva-basic) port so it can be reused and maintained as a proper package. Replaces the abandoned bramdeleeuw/silverstripe-openinghours.

Requirements

  • silverstripe/framework ^6.0
  • spatie/opening-hours ^3.3
  • PHP 8.3+

Installation

composer require xddesigners/silverstripe-openinghours

Usage

Apply an extension to the model that should have opening hours, then dev/build:

# app/_config/openinghours.yml
Viva\Basic\Models\Store:
  extensions:
    - XD\OpeningHours\ExtendedOpeningHours
  • XD\OpeningHours\OpeningHours — base extension: adds the OpeningHour (per-weekday) and OpeningHourException (date-range) has_many relations, CMS GridFields, and helpers such as isOpen() / getOpeningHoursQuery() (a Spatie\OpeningHours\OpeningHours instance).
  • XD\OpeningHours\ExtendedOpeningHours — adds OpeningHoursWithExceptions(), a per-weekday ArrayList (Days/From/Till/IsClosed/Reason) that already folds in exceptions, ready for templates.

Classes

Class Purpose
OpeningHours Extension: relations, CMS fields, spatie query builder, open/closed helpers
ExtendedOpeningHours Extension subclass: per-weekday list including exceptions
OpeningHour DataObject: one weekday's time range
OpeningHourException DataObject: a date-range exception (closed / different hours)
GridFieldConfig_OpeningHours CMS GridField config for the weekly hours
GridFieldConfig_OpeningHoursException CMS GridField config for exceptions