feat: extend module platform with UI slots, runtime components, CLI tooling and {{userId}} search support
Completes the generic module platform that enables modules to contribute
UI elements, runtime JS components, and search resources without any
core hardcoding.
New generic UI slot types:
- topbar.right_item: module-contributed topbar buttons
- layout.body_end_template: module-contributed dialog/overlay templates
- layout.head_style: module-contributed global CSS
- runtime.component: declarative JS component registration with phase ordering
New infrastructure:
- ModuleAutoloader: PSR-4 autoloading for module-local PHP classes
- ModuleRuntimePageBuilder: symlinks module pages into runtime directory
- ModuleRuntimeAssetPublisher: publishes module CSS/JS to web/modules/
- ModulePermissionSynchronizer: syncs module permissions to DB
- CLI scripts: module-runtime-sync, module-build, module-migrate,
module-permissions-sync, module-assets-sync
- {{userId}} placeholder in SearchDataService for user-scoped search queries
- Component runtime with phased initialization (early/default/late)
- AppContainer.protectExistingBindings() to prevent module→core overwrites
- Architecture tests: ModuleStructureContractTest, CoreTemplateIsolationTest,
FrontendComponentRuntimeContractTest, AppContainerIsolationContractTest
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
58
tests/Architecture/CoreTemplateIsolationTest.php
Normal file
58
tests/Architecture/CoreTemplateIsolationTest.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Tests\Architecture;
|
||||
|
||||
use FilesystemIterator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RecursiveDirectoryIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
|
||||
final class CoreTemplateIsolationTest extends TestCase
|
||||
{
|
||||
public function testCoreTemplatesDoNotReferenceModuleSpecificLayoutNavKeys(): void
|
||||
{
|
||||
$projectRoot = dirname(__DIR__, 2);
|
||||
$templatesDir = $projectRoot . '/templates';
|
||||
$modulesDir = $projectRoot . '/modules';
|
||||
|
||||
if (!is_dir($templatesDir) || !is_dir($modulesDir)) {
|
||||
self::markTestSkipped('templates/ or modules/ directory missing.');
|
||||
}
|
||||
|
||||
$moduleIds = [];
|
||||
foreach (scandir($modulesDir) ?: [] as $entry) {
|
||||
if ($entry === '.' || $entry === '..') {
|
||||
continue;
|
||||
}
|
||||
if (!is_dir($modulesDir . '/' . $entry)) {
|
||||
continue;
|
||||
}
|
||||
$moduleIds[] = $entry;
|
||||
}
|
||||
|
||||
$violations = [];
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($templatesDir, FilesystemIterator::SKIP_DOTS),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY
|
||||
);
|
||||
|
||||
foreach ($iterator as $file) {
|
||||
if ($file->getExtension() !== 'phtml') {
|
||||
continue;
|
||||
}
|
||||
$path = $file->getPathname();
|
||||
$content = file_get_contents($path);
|
||||
if (!is_string($content)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($moduleIds as $moduleId) {
|
||||
if (preg_match("/layoutNav\[['\"]" . preg_quote($moduleId, '/') . "(\\.|['\"])" . "/", $content) === 1) {
|
||||
$violations[] = str_replace($projectRoot . '/', '', $path) . ' references layoutNav module key for ' . $moduleId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self::assertSame([], $violations, "Core templates reference module layout keys:\n" . implode("\n", $violations));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user