Add PatternUpdateEvent Subscriber Base Class and Validation Tools

Created on 29 January 2025, 2 months ago

Problem/Motivation

The PatternUpdateEvent system was added in previous releases, but writing event subscribers for this event has limited guidance. Making this more intuitive and lightweight to write will ease the process of utilizing this system. The system also fails if a subscriber is run and results in content assignment that is invalid for the latest schema, even if later subscribers would correct this. Adding a way to support this will allow for subscribers to be more easily separable for smaller areas of concern.

Proposed resolution

  • Add a new base class for event subscribers reacting to PatternUpdateEvent to extend
  • Add new getter functions on PatternUpdateEvent class to simplify data access
  • Extend exception handling for PatternUpdateEvent class to allow for handling invalid content during updates

User interface changes

None

API changes

  • New methods added to \Drupal\patternkit\Event\PatternUpdateEvent for easier value accessibility
  • \Drupal\patternkit\Event\PatternUpdateEvent::setContent method now accepts optional second argument to allow for assignment of invalid content that should be fixed before finally saving the updated pattern
  • New \Drupal\patternkit\EventSubscriber\PatternUpdateEventSubscriberBase for easy extension by new event subscribers
  • New \Drupal\patternkit\PatternValidationTrait Trait class for use by services needing to validate pattern content
  • New event subscriber implementation example: \Drupal\patternkit_test\EventSubscriber\PatternUpdateSubscriber

Data model changes

None

✨ Feature request
Status

Active

Version

9.1

Component

Module Core

Created by

πŸ‡ΊπŸ‡ΈUnited States slucero Arkansas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024