- Some minor on request debugger
This commit is contained in:
1 parent
c3e3d6a73a
commit
ba74c5a38e
17 files changed
+255
-202
No files matched your search
+8
-4
@@ -3,7 +3,7 @@
|
||||
namespace Lean\Api\Form;
|
||||
|
||||
use CSLSJ\Lean\Form\Session\EmailContext;
|
||||
use Picea\Ui\Method\{ FormContextInterface, };
|
||||
use Picea\Ui\Method\{FormContext, FormContextInterface};
|
||||
|
||||
use Lean\Api\Attribute\ContextField;
|
||||
use Lean\Api\Exception\MandatoryFieldException;
|
||||
@@ -19,6 +19,8 @@ abstract class Save extends Form implements \Picea\Ui\Method\FormInterface {
|
||||
|
||||
protected array $reflectedProperties;
|
||||
|
||||
protected string $contextClass = FormContext::class;
|
||||
|
||||
public function initialize(FormContextInterface $context) : void
|
||||
{
|
||||
if ( ! $this->getEntity()->isLoaded() ) {
|
||||
@@ -46,12 +48,14 @@ abstract class Save extends Form implements \Picea\Ui\Method\FormInterface {
|
||||
|
||||
if ($entity->isLoaded()) {
|
||||
if (property_exists($entity, 'updatedAt') && $entity->repository()->generateDatasetDiff($entity) ) {
|
||||
$entity->updatedAt = new Datetime();
|
||||
$cls = $entity::resolveEntity()->field('updatedAt')->type->type;
|
||||
$entity->updatedAt = new $cls();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (property_exists($entity, 'createdAt') && empty($entity->createdAt)) {
|
||||
$entity->createdAt = new Datetime();
|
||||
$cls = $entity::resolveEntity()->field('createdAt')->type->type;
|
||||
$entity->createdAt = new $cls();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +86,7 @@ abstract class Save extends Form implements \Picea\Ui\Method\FormInterface {
|
||||
|
||||
if ($attribute) {
|
||||
try {
|
||||
$attribute->object->assertValueSpecs($context->$name ?? null, $this->getEntity()->isLoaded());
|
||||
$attribute->object->assertValueSpecs($context->$name ?? null, ! $this->getEntity()->isLoaded());
|
||||
} catch (MandatoryFieldException $e) {
|
||||
throw new MandatoryFieldException("An error occured with field '$name': " . $e->getMessage());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user