Skip to content

isWorkingDay(): replace the hard-coded Holiday add-on file with a hook #565

Open

Description

@caseysoftware

w2p_Utilities_Date::isWorkingDay() (classes/w2p/Utilities/Date.class.php L181–206) special-cases one add-on. It checks isActiveModule('holiday'), requires modules/holiday/holiday_functions.class.php, and calls HolidayFunctions::isHoliday($this).

As a result:

Proposal: a hook gathered by w2p_System_HookHandler, e.g. hook_nonWorkingDates(w2p_Utilities_Date $start, w2p_Utilities_Date $end, ?int $userId): array returning ['Y-m-d' => true|false] (false = an extra working day). Core would:

  • call it once per span and cache the result per request
  • catch Throwable per module, as calendar() and calendar_links() already do
  • keep cal_working_days as the base rule

The optional $userId would let a module apply per-user absence if core later passes the task assignee (web2project/modules-holiday#12).

The Holiday add-on would then implement the hook instead of being required by path.

Found while reviewing the Holiday add-on for 5.0: web2project/modules-holiday#1.

Effort: M

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions