refactor(autoload): migrate theme classes to Composer PSR-4
Move 288 types from global AKSRT_* + inc/classes manual requires into
namespace AKSRT\{Domain} under src/AKSRT/, wire composer.json psr-4,
and slim bootstrap to helpers/modules/hooks only. Split multi-class
widget/gateway files, update admin contract audit paths, and document
the layout in ADR/README.
This commit is contained in:
@@ -43,16 +43,16 @@ function collect_php_schema_sections(string $themeRoot): array {
|
||||
|
||||
// Primary domain builders.
|
||||
$primary = [
|
||||
'global' => $themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-global.php',
|
||||
'page_display' => $themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-page-display.php',
|
||||
'post_list' => $themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-post-list.php',
|
||||
'permissions' => $themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-permissions.php',
|
||||
'users' => $themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-users.php',
|
||||
'payment' => $themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-payment.php',
|
||||
'extensions' => $themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-extensions.php',
|
||||
'tools' => $themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-tools.php',
|
||||
'shop' => $themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-shop.php',
|
||||
'forum' => $themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-forum.php',
|
||||
'global' => $themeRoot . '/src/AKSRT/Admin/Schema/GlobalSchema.php',
|
||||
'page_display' => $themeRoot . '/src/AKSRT/Admin/Schema/SchemaPageDisplay.php',
|
||||
'post_list' => $themeRoot . '/src/AKSRT/Admin/Schema/SchemaPostList.php',
|
||||
'permissions' => $themeRoot . '/src/AKSRT/Admin/Schema/SchemaPermissions.php',
|
||||
'users' => $themeRoot . '/src/AKSRT/Admin/Schema/SchemaUsers.php',
|
||||
'payment' => $themeRoot . '/src/AKSRT/Admin/Schema/SchemaPayment.php',
|
||||
'extensions' => $themeRoot . '/src/AKSRT/Admin/Schema/SchemaExtensions.php',
|
||||
'tools' => $themeRoot . '/src/AKSRT/Admin/Schema/SchemaTools.php',
|
||||
'shop' => $themeRoot . '/src/AKSRT/Admin/Schema/SchemaShop.php',
|
||||
'forum' => $themeRoot . '/src/AKSRT/Admin/Schema/SchemaForum.php',
|
||||
];
|
||||
|
||||
foreach ($primary as $domain => $file) {
|
||||
@@ -75,7 +75,7 @@ function collect_php_schema_sections(string $themeRoot): array {
|
||||
}
|
||||
|
||||
// Leaf builders that return a single section with 'key' => 'section-id'
|
||||
$leafFiles = glob($themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-*.php') ?: [];
|
||||
$leafFiles = array_merge(glob($themeRoot . '/src/AKSRT/Admin/Schema/*.php') ?: [], glob($themeRoot . '/src/AKSRT/Admin/Schema/*/*.php') ?: []);
|
||||
foreach ($leafFiles as $file) {
|
||||
$src = file_get_contents($file);
|
||||
if ($src === false) {
|
||||
@@ -92,7 +92,7 @@ function collect_php_schema_sections(string $themeRoot): array {
|
||||
$section = $km[1];
|
||||
// Infer domain from filename: class-aksrt-admin-schema-{domain}-{section}.php
|
||||
$base = basename($file, '.php');
|
||||
$base = preg_replace('/^class-aksrt-admin-schema-/', '', $base);
|
||||
$base = preg_replace('/^(class-aksrt-admin-schema-|Schema)/', '', $base);
|
||||
$parts = explode('-', $base);
|
||||
// domain may be multi-token (page_display is page-display in menus but page_display in PHP).
|
||||
// Prefer matching known domains by prefix.
|
||||
@@ -105,8 +105,17 @@ function collect_php_schema_sections(string $themeRoot): array {
|
||||
}
|
||||
}
|
||||
if ($domain === null) {
|
||||
// Fallback: first token.
|
||||
$domain = str_replace('-', '_', $parts[0] ?? '');
|
||||
// Fallback: first token / PSR-4 Schema* short names.
|
||||
if (str_contains($base, 'PostList')) {
|
||||
$domain = 'post_list';
|
||||
} else {
|
||||
$domain = str_replace('-', '_', $parts[0] ?? '');
|
||||
}
|
||||
}
|
||||
// Leaf under Schema/PostList/ with key list → post_list/list
|
||||
if ($domain === 'post_list' && $section === 'list') {
|
||||
$register($domain, $section, $file);
|
||||
continue;
|
||||
}
|
||||
$register($domain, $section, $file);
|
||||
}
|
||||
@@ -160,7 +169,7 @@ function collect_enum_maps(string $themeRoot): array {
|
||||
$php = [];
|
||||
$js = [];
|
||||
|
||||
$phpFiles = glob($themeRoot . '/inc/classes/admin/schema/class-aksrt-admin-schema-*.php') ?: [];
|
||||
$phpFiles = array_merge(glob($themeRoot . '/src/AKSRT/Admin/Schema/*.php') ?: [], glob($themeRoot . '/src/AKSRT/Admin/Schema/*/*.php') ?: []);
|
||||
foreach ($phpFiles as $file) {
|
||||
$src = file_get_contents($file);
|
||||
if ($src === false) {
|
||||
@@ -230,9 +239,16 @@ function collect_enum_maps(string $themeRoot): array {
|
||||
|
||||
function collect_missing_this_callbacks(string $themeRoot): array {
|
||||
$issues = [];
|
||||
$adminRoot = $themeRoot . '/inc/classes/admin';
|
||||
$adminRoot = $themeRoot . '/src/AKSRT/Admin';
|
||||
if (!is_dir($adminRoot)) {
|
||||
$adminRoot = $themeRoot . '/inc/classes/admin';
|
||||
}
|
||||
$methodIndex = [];
|
||||
|
||||
if (!is_dir($adminRoot)) {
|
||||
return $issues;
|
||||
}
|
||||
|
||||
$allPhp = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($adminRoot, FilesystemIterator::SKIP_DOTS));
|
||||
foreach ($allPhp as $file) {
|
||||
if ($file->getExtension() !== 'php') {
|
||||
|
||||
Reference in New Issue
Block a user