- Some work done on entity generation
This commit is contained in:
1 parent
05975089e5
commit
2dc71cd350
12 files changed
+94
-28
No files matched your search
+8
-3
@@ -14,16 +14,21 @@ use Lean\Api\Attribute\EntityField;
|
||||
|
||||
use Ulmus\Entity\EntityInterface;
|
||||
use Ulmus\Entity\Field\Datetime;
|
||||
use Ulmus\EntityCollection;
|
||||
|
||||
abstract class Save extends Form implements \Picea\Ui\Method\FormInterface {
|
||||
|
||||
protected bool $skipEntityCreatedAt = false;
|
||||
|
||||
protected bool $skipEntityLastModified = false;
|
||||
|
||||
protected array $reflectedProperties;
|
||||
|
||||
protected string $contextClass = FormContext::class;
|
||||
|
||||
public function initialize(FormContextInterface $context) : void
|
||||
{
|
||||
if ( ! $this->getEntity()->isLoaded() ) {
|
||||
if ( $this->getEntity() instanceof EntityInterface && ! $this->getEntity()->isLoaded() ) {
|
||||
if (method_exists($context, 'initializeEntity')) {
|
||||
$context->initializeEntity($this->getEntity());
|
||||
}
|
||||
@@ -46,13 +51,13 @@ abstract class Save extends Form implements \Picea\Ui\Method\FormInterface {
|
||||
{
|
||||
$entity = $this->getEntity();
|
||||
|
||||
if ($entity->isLoaded()) {
|
||||
if ($entity->isLoaded() && ! $this->skipEntityLastModified) {
|
||||
if (property_exists($entity, 'updatedAt') && $entity->repository()->generateDatasetDiff($entity) ) {
|
||||
$cls = $entity::resolveEntity()->field('updatedAt')->type->type;
|
||||
$entity->updatedAt = new $cls();
|
||||
}
|
||||
}
|
||||
else {
|
||||
elseif (! $this->skipEntityCreatedAt) {
|
||||
if (property_exists($entity, 'createdAt') && empty($entity->createdAt)) {
|
||||
$cls = $entity::resolveEntity()->field('createdAt')->type->type;
|
||||
$entity->createdAt = new $cls();
|
||||
|
||||
Reference in new issue
Block a user