Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new Laravel-scoped TemplateCaches service in src/ with a collector-based architecture for caching template fragments (dependencies, resources, and legacy Yii2 asset bundles), and migrates legacy Yii2-adapter services/tests to use or integrate with it.
Changes:
- Added
CraftCms\Cms\View\TemplateCachesplus aCacheCollectorInterface,TemplateCacheContext, andRegisterTemplateCacheCollectorsevent to support pluggable cache payload collection/apply. - Implemented core collectors (
DependencyCollector,ResourceCollector) and a Yii2-adapter collector (LegacyAssetBundleCollector) wired viaYii2ServiceProvider. - Updated Twig cache node compilation output and added unit tests + Yii2-adapter tests to validate collector registration and replay behavior.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/View/TemplateCaches.php |
New template fragment cache service; stores collector payloads and dependency info. |
src/View/CacheCollectors/DependencyCollector.php |
New dependency/tag+expiry collection and nesting merge behavior. |
src/View/CacheCollectors/ResourceCollector.php |
Captures/reapplies HtmlStack buffered resources for cached fragments. |
src/View/Contracts/CacheCollectorInterface.php |
Collector contract for begin/end/apply. |
src/View/Data/TemplateCacheContext.php |
Context passed to collectors (cacheKey/global/resources). |
src/View/Events/RegisterTemplateCacheCollectors.php |
Event to register additional collectors. |
src/Twig/Nodes/CacheNode.php |
Compiles to resolve cache service from the container. |
tests/Unit/View/TemplateCachesTest.php |
Unit tests for collector event dispatch, payload application, and scoping. |
tests/Unit/View/DependencyCollectorTest.php |
Unit tests for dependency collector nesting and expiry selection. |
tests/Unit/View/ResourceCollectorTest.php |
Unit tests for capturing and replaying buffered resources. |
tests/Unit/Http/RequestMixinTest.php |
Tests for Request macro behavior after moving to a mixin class. |
src/Providers/AppServiceProvider.php |
Replaces inline Request macros with RequestMixin. |
src/Http/Mixins/RequestMixin.php |
Centralizes Request macro implementations. |
yii2-adapter/legacy/services/TemplateCaches.php |
Deprecates legacy service and delegates to new TemplateCaches. |
yii2-adapter/legacy/services/Elements.php |
Routes element cache info collection through DependencyCollector. |
yii2-adapter/src/View/LegacyAssetBundleCollector.php |
Collector to capture/replay legacy Yii2 asset bundle registrations. |
yii2-adapter/src/Yii2ServiceProvider.php |
Registers legacy collector via RegisterTemplateCacheCollectors event. |
yii2-adapter/tests-laravel/View/*.php |
Yii2-adapter tests covering collector registration and asset bundle replay. |
yii2-adapter/tests-laravel/Pest.php |
Includes new View test folder. |
tests/.pest/snapshots/...CacheNodeTest/*.snap |
Snapshot updates for new compiled cache service resolution. |
src/Element/Queries/Concerns/HydratesElements.php |
Uses DependencyCollector for expiry date collection while hydrating. |
src/Element/Queries/Concerns/CollectsCacheTags.php |
Uses DependencyCollector for collecting query cache tags. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.