Skip to content

[6.x] Consolidate CP config data into Cp::config()#18829

Draft
brianjhanson wants to merge 1 commit into
6.xfrom
claude/unruffled-matsumoto-6e0f6a
Draft

[6.x] Consolidate CP config data into Cp::config()#18829
brianjhanson wants to merge 1 commit into
6.xfrom
claude/unruffled-matsumoto-6e0f6a

Conversation

@brianjhanson
Copy link
Copy Markdown
Contributor

Summary

  • Moves all window.Craft data assembly out of the deprecated CpAsset::_craftData() and into Cp::config(), making it the single source of truth for both the Inertia/Vue bootstrap and the legacy Twig/jQuery path
  • Moves the private helper methods (datepickerOptions, timepickerOptions, sites, publishableSections, etc.) to the Cp class as private static methods
  • CpAsset::register() now delegates to Cp::config() — the class is reduced to just asset registration logic

Test plan

  • Load a legacy Twig CP page and confirm window.Craft is populated correctly
  • Load an Inertia CP page and confirm the Vue app bootstraps as expected (CpConfig in app.blade.php)
  • Spot-check a few window.Craft values (translations, user data, site list) in both paths

🤖 Generated with Claude Code

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>
@brianjhanson brianjhanson requested a review from Copilot May 11, 2026 16:05
@brianjhanson brianjhanson changed the title Consolidate CP config data into Cp::config() [6.x] Consolidate CP config data into Cp::config() May 11, 2026
@brianjhanson brianjhanson marked this pull request as draft May 11, 2026 16:06
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 into Cp as private static methods.
  • Updated deprecated CpAsset::register() to populate window.Craft using Cp::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

Comment thread src/Cp/Cp.php

if (request()->isCpRequest()) {
$data += [
'announcements' => $upToDate ? app(Announcements::class)->get() : [],
Comment thread src/Cp/Cp.php
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'],
]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants