[6.x] Consolidate CP config data into Cp::config()#18829
Draft
brianjhanson wants to merge 1 commit into
Draft
Conversation
Moves all `window.Craft` data assembly from `CpAsset::_craftData()` into `Cp::config()` so both the Inertia Vue bootstrap and legacy Twig/jQuery path share a single source of truth. `CpAsset` is now a thin registration wrapper that delegates to `Cp::config()`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR centralizes Craft Control Panel (CP) bootstrap/config data generation by moving the legacy window.Craft payload assembly out of the deprecated CpAsset::_craftData() and into Cp::config(), aiming to make Cp::config() the single source of truth for both legacy Twig/jQuery CP pages and the Inertia/Vue CP bootstrap.
Changes:
- Refactored CP bootstrap data generation into
Cp::config()and moved related helper methods intoCpasprivate staticmethods. - Updated deprecated
CpAsset::register()to populatewindow.CraftusingCp::config()instead of its own private assembler. - Expanded
Cp::config()from a small Collection-based config to a full legacy-equivalent config array.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/View/LegacyAssets/CpAsset.php | Switches legacy window.Craft initialization to use Cp::config() |
| src/Cp/Cp.php | Implements the consolidated CP config payload and helper methods |
|
|
||
| if (request()->isCpRequest()) { | ||
| $data += [ | ||
| 'announcements' => $upToDate ? app(Announcements::class)->get() : [], |
Comment on lines
+202
to
+212
| $parsed = parse_url($generalConfig->httpProxy); | ||
|
|
||
| return array_filter([ | ||
| 'host' => $parsed['host'], | ||
| 'port' => $parsed['port'] ?? strtolower($parsed['scheme']) === 'http' ? 80 : 443, | ||
| 'auth' => array_filter([ | ||
| 'username' => $parsed['user'] ?? null, | ||
| 'password' => $parsed['pass'] ?? null, | ||
| ]), | ||
| 'protocol' => $parsed['scheme'], | ||
| ]); |
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.
Summary
window.Craftdata assembly out of the deprecatedCpAsset::_craftData()and intoCp::config(), making it the single source of truth for both the Inertia/Vue bootstrap and the legacy Twig/jQuery pathdatepickerOptions,timepickerOptions,sites,publishableSections, etc.) to theCpclass asprivate staticmethodsCpAsset::register()now delegates toCp::config()— the class is reduced to just asset registration logicTest plan
window.Craftis populated correctlyCpConfiginapp.blade.php)window.Craftvalues (translations, user data, site list) in both paths🤖 Generated with Claude Code