Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -4,46 +4,48 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Router;
|
||||
|
||||
use App\Framework\Core\ValueObjects\ClassName;
|
||||
use App\Framework\DI\DefaultContainer;
|
||||
use App\Framework\Http\Request;
|
||||
use App\Framework\Http\RequestBody;
|
||||
use App\Framework\Http\Session\Session;
|
||||
use App\Framework\Reflection\ReflectionProvider;
|
||||
use App\Framework\Reflection\WrappedReflectionClass;
|
||||
use App\Framework\Validation\Exceptions\ValidationException;
|
||||
use App\Framework\Validation\Validator;
|
||||
use Exception;
|
||||
use ReflectionClass;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionProperty;
|
||||
|
||||
final readonly class ControllerRequestFactory
|
||||
{
|
||||
public function __construct(
|
||||
private DefaultContainer $container,
|
||||
private PropertyValueConverter $propertyValueConverter
|
||||
) {}
|
||||
private PropertyValueConverter $propertyValueConverter,
|
||||
private ReflectionProvider $reflectionProvider
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Erstellt und validiert eine ControllerRequest-Instanz
|
||||
*/
|
||||
public function createAndValidate(ReflectionClass $requestClass, RequestBody $data): object
|
||||
public function createAndValidate(WrappedReflectionClass $requestClass, RequestBody $data): object
|
||||
{
|
||||
// Instanz erstellen
|
||||
$instance = $requestClass->newInstance();
|
||||
// Native ReflectionClass für Instanziierung holen
|
||||
$className = ClassName::create($requestClass->getName());
|
||||
|
||||
// Eigenschaften befüllen und validieren
|
||||
foreach ($requestClass->getProperties() as $property) {
|
||||
$class = $this->reflectionProvider->getClass($className);
|
||||
|
||||
// Erst die Instanz erstellen
|
||||
$instance = $class->newInstance();
|
||||
|
||||
$properties = $requestClass->getProperties();
|
||||
|
||||
foreach ($properties as $property) {
|
||||
$propertyName = $property->getName();
|
||||
|
||||
// Wert aus den Daten abrufen
|
||||
$value = $data->get($propertyName, null);
|
||||
|
||||
try {
|
||||
// Jetzt auf die tatsächliche Instanz setzen
|
||||
$this->propertyValueConverter->setPropertyValue($property, $instance, $value);
|
||||
} catch (\Throwable $e) {
|
||||
#throw new ValidationException(
|
||||
# ['Ungültiger Wert für den Typ: ' . $e->getMessage()],
|
||||
# $propertyName
|
||||
#);
|
||||
// Fehler beim Setzen ignorieren
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +54,6 @@ final readonly class ControllerRequestFactory
|
||||
$validationResult = $validator->validate($instance);
|
||||
|
||||
if ($validationResult->hasErrors()) {
|
||||
|
||||
throw new ValidationException($validationResult, 'test');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user