Skip to content

Update Loader to support Task Handlers#6

Merged
alexstandiford merged 2 commits into
mainfrom
alexstandiford-patch-1
May 28, 2025
Merged

Update Loader to support Task Handlers#6
alexstandiford merged 2 commits into
mainfrom
alexstandiford-patch-1

Conversation

@alexstandiford
Copy link
Copy Markdown
Contributor

Context

This PR adds support for the new phpnomad/tasks system by updating the CanLoadInitializers trait to recognize and process initializers that implement HasTaskHandlers.

The new task system introduced in phpnomad/tasks v2.0.0 aligns closely with PHPNomad’s event architecture, allowing developers to define tasks as value objects and register one or more handlers to be executed in sequence. Like events, tasks are registered declaratively via initializers, and their dispatch logic is delegated to a platform-specific TaskStrategy.

What Changed

  • The loader now detects if an initializer implements HasTaskHandlers.
  • When present, it retrieves the task-to-handler mappings and registers them with the active TaskStrategy instance via attach().
  • This mirrors how HasListeners is handled for events and supports multiple handlers per task class.

Why This Matters

The addition ensures that the task system fully integrates with the PHPNomad bootstrap lifecycle and adheres to the same modular, initializer-driven design used throughout the framework.

By delegating handler registration to the loader:

  • Integrations can cleanly register task pipelines without imperative code.
  • The task system becomes first-class within PHPNomad.
  • Dispatch and execution are decoupled from the application core, supporting immediate, queued, or deferred workflows depending on the configured strategy.

This update is necessary for any system adopting the new task architecture and completes the foundational work needed to support task execution across platforms like WordPress, Redis, or CLI.

@alexstandiford alexstandiford merged commit 92deb40 into main May 28, 2025
0 of 3 checks passed
@alexstandiford alexstandiford changed the title Alexstandiford patch 1 Update Loader to support Task Handlers May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant