Files
michaelschiemer/tests/debug/test-presave-discovery.php
Michael Schiemer 5050c7d73a docs: consolidate documentation into organized structure
- Move 12 markdown files from root to docs/ subdirectories
- Organize documentation by category:
  • docs/troubleshooting/ (1 file)  - Technical troubleshooting guides
  • docs/deployment/      (4 files) - Deployment and security documentation
  • docs/guides/          (3 files) - Feature-specific guides
  • docs/planning/        (4 files) - Planning and improvement proposals

Root directory cleanup:
- Reduced from 16 to 4 markdown files in root
- Only essential project files remain:
  • CLAUDE.md (AI instructions)
  • README.md (Main project readme)
  • CLEANUP_PLAN.md (Current cleanup plan)
  • SRC_STRUCTURE_IMPROVEMENTS.md (Structure improvements)

This improves:
 Documentation discoverability
 Logical organization by purpose
 Clean root directory
 Better maintainability
2025-10-05 11:05:04 +02:00

129 lines
4.3 KiB
PHP

<?php
declare(strict_types=1);
require __DIR__ . '/../../vendor/autoload.php';
use App\Framework\Performance\EnhancedPerformanceCollector;
use App\Framework\DateTime\SystemClock;
use App\Framework\DateTime\SystemHighResolutionClock;
use App\Framework\Performance\MemoryMonitor;
use App\Framework\Core\AppBootstrapper;
use App\Framework\Discovery\Results\DiscoveryRegistry;
use App\Framework\Attributes\Route;
echo "=== PreSaveCampaign Discovery Test ===" . PHP_EOL . PHP_EOL;
// Bootstrap application
$basePath = dirname(__DIR__, 2);
$clock = new SystemClock();
$highResClock = new SystemHighResolutionClock();
$memoryMonitor = new MemoryMonitor();
$collector = new EnhancedPerformanceCollector($clock, $highResClock, $memoryMonitor, enabled: false);
$bootstrapper = new AppBootstrapper($basePath, $collector, $memoryMonitor);
$app = $bootstrapper->bootstrapWeb();
// Get Discovery Registry from Container
$reflection = new ReflectionClass($app);
$containerProperty = $reflection->getProperty('container');
$containerProperty->setAccessible(true);
$container = $containerProperty->getValue($app);
/** @var DiscoveryRegistry $registry */
$registry = $container->get(DiscoveryRegistry::class);
echo "Discovery Registry Stats:" . PHP_EOL;
echo " Total Attributes: " . count($registry->attributes->getAll()) . PHP_EOL;
// Get all Route attributes
$routes = $registry->attributes->get(Route::class);
echo " Total Routes: " . count($routes) . PHP_EOL . PHP_EOL;
// Search for Campaign routes
echo "Campaign Routes:" . PHP_EOL;
$campaignRoutes = [];
foreach ($routes as $route) {
$className = $route->className->getFullyQualified();
if (str_contains($className, 'Campaign')) {
$campaignRoutes[] = $route;
// Get route details
$routeAttr = $route->createAttributeInstance();
if ($routeAttr instanceof Route) {
echo " ✅ Found: {$className}::{$route->methodName}" . PHP_EOL;
echo " Path: {$routeAttr->path}" . PHP_EOL;
echo " Method: {$routeAttr->method->value}" . PHP_EOL;
}
}
}
if (empty($campaignRoutes)) {
echo " ❌ NO Campaign routes found in discovery!" . PHP_EOL;
}
echo PHP_EOL;
// Specifically check for PreSaveCampaign
echo "PreSaveCampaign Check:" . PHP_EOL;
$found = false;
foreach ($routes as $route) {
if ($route->className->getShortName() === 'PreSaveCampaign') {
$found = true;
$routeAttr = $route->createAttributeInstance();
echo " ✅ PreSaveCampaign found!" . PHP_EOL;
echo " Full Class: {$route->className->getFullyQualified()}" . PHP_EOL;
echo " Method: {$route->methodName}" . PHP_EOL;
if ($routeAttr instanceof Route) {
echo " Path: {$routeAttr->path}" . PHP_EOL;
echo " HTTP Method: {$routeAttr->method->value}" . PHP_EOL;
}
break;
}
}
if (!$found) {
echo " ❌ PreSaveCampaign NOT found in discovery!" . PHP_EOL;
echo PHP_EOL;
echo "Checking if file exists:" . PHP_EOL;
$file = $basePath . '/src/Application/Campaign/PreSaveCampaign.php';
if (file_exists($file)) {
echo " ✅ File exists: $file" . PHP_EOL;
// Check if class can be loaded
if (class_exists('App\\Application\\Campaign\\PreSaveCampaign')) {
echo " ✅ Class can be loaded" . PHP_EOL;
$reflection = new ReflectionClass('App\\Application\\Campaign\\PreSaveCampaign');
$attributes = $reflection->getAttributes(Route::class);
echo " Found " . count($attributes) . " Route attributes on class" . PHP_EOL;
foreach ($reflection->getMethods() as $method) {
$methodAttrs = $method->getAttributes(Route::class);
if (count($methodAttrs) > 0) {
echo " ✅ Found Route on method: {$method->getName()}" . PHP_EOL;
foreach ($methodAttrs as $attr) {
$routeInstance = $attr->newInstance();
echo " Path: {$routeInstance->path}" . PHP_EOL;
}
}
}
} else {
echo " ❌ Class cannot be loaded!" . PHP_EOL;
}
} else {
echo " ❌ File does NOT exist: $file" . PHP_EOL;
}
}
echo PHP_EOL . "=== Summary ===" . PHP_EOL;
echo "Discovery funktioniert für Campaign-Routes: " . ($found ? "✅ JA" : "❌ NEIN") . PHP_EOL;