45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Lean\Api\Form\Debug;
|
|
|
|
use Lean\Api\{Entity};
|
|
use Lean\Api\Attribute\ContextField;
|
|
use Picea\Ui\Method\FormContext;
|
|
use Ulmus\Api\Common\MethodEnum;
|
|
use Ulmus\Entity\Field\Datetime;
|
|
|
|
#[ContextField(description: "This form saves an error received by the API")]
|
|
class ErrorContext extends FormContext
|
|
{
|
|
#[ContextField(description: "URL which the error was received from", hidden: true, )]
|
|
public string $url;
|
|
|
|
#[ContextField( description: "HTTP method used when this error was generated", hidden: true, )]
|
|
public MethodEnum|string $httpMethod;
|
|
|
|
#[ContextField(description: "Error message generated")]
|
|
public string $message;
|
|
|
|
#[ContextField(description: "HTTP error code")]
|
|
public int $code;
|
|
|
|
#[ContextField(description: "File in which the error occured")]
|
|
public string $file;
|
|
|
|
#[ContextField(description: "Line of the error")]
|
|
public int $line;
|
|
|
|
#[ContextField(description: "Complete stack trace (when available)")]
|
|
public array $trace;
|
|
|
|
public function valid(? Entity\Error $error = null): bool
|
|
{
|
|
$server = $this->getRequest()->getServerParams();
|
|
|
|
$this->url = ( ( 'on' === ( $server['HTTPS'] ?? false ) ) ? 'https' : 'http' ) . '://' . $server['HTTP_HOST'] . $server["REQUEST_URI"];
|
|
|
|
$this->httpMethod = MethodEnum::from($server['REQUEST_METHOD']);
|
|
|
|
return parent::valid();
|
|
}
|
|
} |