DWS WP Framework
  • Welcome
  • Primary goals
    • Modular design
    • No 3rd-party dependencies
  • Key concepts and dev tools
    • PHP and WP requirements
    • Object-Oriented Programming
    • Semantic Versioning
    • Version Control (git / GitHub)
    • Dependency Management (Composer)
    • Automated Testing (Codeception + Github Actions)
    • Dependency Injection (PHP-DI)
    • Coding Standards (PHPCS and PHPMD)
    • Dependencies Scoping (PHP-Scoper)
    • TypeScript and Sass
    • Task Runners (Grunt)
  • Setting up your dev environment
    • Windows
  • Your first plugin
    • Multiple plugins using the framework on the same site
  • Frequently Asked Questions
  • Bootstrapper Module
    • Motivation
    • How it works
    • How to use
    • White Labeling
  • Helpers Module
    • Motivation
    • How to use
  • Foundations Module
    • Motivation and How to use
    • Actions
      • Local action traits
      • Extension action traits
      • Integration action traits
    • States
    • Utilities
      • Stores
      • Handlers and Services
        • Logging Service
  • Plugin
    • Main Plugin Instance
    • Plugin Components
  • Hierarchies
  • Helpers
  • Utilities Module
    • Motivation and How to use
    • Hooks Service
      • Scoped Handler
    • Shortcodes Service
    • Templating Service
    • Assets Service
      • Scripts Handler
      • Styles Handler
    • CRON Events Service
      • Action Scheduler Handler
    • Admin Notices Service
    • Dependencies Service
    • Validation Service
  • Core Module
    • Motivation and How to use
    • Plugin Tree
      • Plugin Root
      • Plugin Functionality
    • Plugin Components
      • Internationalization
      • Installation / Upgrade / Uninstallation
  • Settings Module
    • Motivation and How to use
    • Settings Service
      • WordPress Handler
      • MetaBox Handler
      • ACF Handler
    • Validated Settings
  • WooCommerce Module
    • Motivation and How to use
    • Extended WC Logger
    • WC Settings Handler
Powered by GitBook
On this page

Was this helpful?

  1. Foundations Module
  2. Utilities

Handlers and Services

PreviousStoresNextLogging Service

Last updated 4 years ago

Was this helpful?

and are two distinct concepts, but they were designed together and are being used together. Specifically, services make use of handlers. Handlers, however, can be freely used in other contexts as well.

Handlers are that also implement a get_type method. For example, handlers for the are of the logging type.

Services are meant to be central hubs (i.e., singleton instances) for performing certain actions. It's not mandatory, but we designed all of our services to delegate the responsibility of performing the actions to a handler. For example, a service inheriting the class always performs the actions with the same handler whereas a service inheriting the class needs to be instructed which registered handler to use.

Handlers are not meant to be used directly. An object usually has one-or-more registered handlers that it can perform actions with. That's why the (and the corresponding ) and the (and the corresponding ) are very important.

The handlers are also prime candidates for . There are 3 traits that the foundations module comes with:

  • -- using objects will call the output method of their registered handlers.

  • -- using objects will call the run method of their registered handlers

  • -- using objects will call the reset method of their registered handlers.

For example, a implementing the and using the OutputHandlersTrait mentioned above will automagically call the output method of all its registered handlers also implementing the OutputtableInterface when the service's own output method is called. Pretty neat, huh?

Handlers
Services
storable objects
logging service
AbstractHandlerService
AbstractMultiHandlerService
HandlerAwareInterface
trait
MultiHandlerAwareInterface
trait
extension action traits
OutputHandlersTrait
RunHandlersTrait
ResetHandlersTrait
multi-handler-aware-service
OutputtableInterface