- Lean's API WIP on forms and ApiRenderer
This commit is contained in:
1 parent
3ce356e1f2
commit
4d7053a9cb
30 files changed
+1003
-56
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user