Add basic events and plugins functionality - #812
Conversation
7abf8e7 to
97d81f5
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a comprehensive event system, plugin infrastructure, and refactored asset/view management to enable extensibility in Formwork CMS. The changes allow plugins to hook into application lifecycle events, provide namespaced assets and views, and extend core functionality.
Key Changes:
- Event system with dispatcher and lifecycle events (page operations, routing, exceptions, responses)
- Plugin infrastructure with automatic event listener discovery, manifest support, and resource loading
- Namespaced asset and view resolution (e.g.,
@panel/css/panel.min.css,@panel.users.index)
Reviewed changes
Copilot reviewed 113 out of 115 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| formwork/src/Events/* | New event system with EventDispatcher and Event base class |
| formwork/src/Plugins/* | Complete plugin infrastructure including Plugin, Plugins manager, PluginFactory, and PluginManifest |
| formwork/src/Assets/Assets.php | Refactored to support namespaced asset resolution with multiple resolution paths |
| formwork/src/View/View.php | Updated to support namespaced view resolution with @namespace.view.name syntax |
| formwork/src/Cms/App.php | Integrated event dispatching at key lifecycle points and registered new services |
| formwork/src/Router/Router.php | Added action parameters support for dependency injection |
| formwork/src/Utils/Str.php | Added case conversion methods (toCamelCase, toDashCase, toSnakeCase) |
| formwork/src/Services/Loaders/* | New service loaders for Assets and Plugins |
| panel/views/**/*.php | Updated all panel views to use namespaced syntax (@panel.*) |
| formwork/views/**/*.php | Updated system views to use namespaced syntax (@system.*) |
| formwork/config/system.yaml | Added plugin configuration section |
| .gitignore | Excluded plugin-related directories |
| formwork/.php-cs-fixer.php | Excluded site/plugins from code style checks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 114 out of 116 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fe92928 to
aa1b754
Compare
aa1b754 to
499928a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 113 out of 115 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 113 out of 115 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This pull request introduces several significant changes to the Formwork CMS, focusing on extensibility, asset management, and event handling. The most impactful updates include a new event system for key application lifecycle moments, a refactored asset resolution mechanism with support for namespaced assets, and the addition of a plugin infrastructure. There are also configuration and service registration changes to support these new features.
Event System Enhancements:
ExceptionThrownEvent,ResponseBeforeSendEvent,RoutesBeforeLoadEvent,RoutesAfterLoadEvent) and integrated them into the application flow. This allows plugins and other components to hook into these moments. [1] [2] [3] [4] [5] [6] [7] [8]Asset Management Refactor:
Assetsservice to support resolution paths for namespaced assets, allowing assets to be organized and referenced by namespace. Added a newAssetResolutionExceptionfor error handling. [1] [2] [3] [4] [5] [6]Assetsservice via dependency injection, and exposed it through theAppclass. [1] [2] [3]Plugin Infrastructure:
Pluginsservice in the application lifecycle. [1] [2] [3] [4] [5]Configuration and Service Loader Updates:
Tooling and Exclusion Patterns:
.php-cs-fixer.php,.rector.php,phpstan.neon) to exclude the newsite/pluginsdirectory from code analysis and formatting tools. [1] [2] [3]Other minor changes include the addition of the
assetsview method and a fix to use the correct namespaced template for error views. [1] [2] [3] [4] [5]