entity = $entity; $this->datasetFillEvent = new class() implements \Ulmus\Event\Entity\DatasetFill { public readonly array $data; public function execute(\Generator $generator, \Ulmus\Entity\EntityInterface $entity): void { $this->data = $entity::repository()->generateDatasetDiff($entity); } }; $this->entity->eventRegister($this->datasetFillEvent); } public function initializeEntity(\Lean\Api\Entity\Security\ApiActionLog $actionLog) : void { if (isset($this->entity) && $this->entity->isLoaded()) { $this->object_type = $this->entity::class; if (isset($this->datasetFillEvent->data)) { $this->data = $this->datasetFillEvent->data; } $pk = $this->entity::resolveEntity()->getPrimaryKeyField(); if ($pk) { $pk = array_key_first($this->entity::resolveEntity()->getPrimaryKeyField()); if (isset($this->entity->$pk)) { $this->object_id = $this->entity->$pk; } } elseif ($index = $this->entity::resolveEntity()->getCompoundKeyFields()) { if ($index->type === IndexTypeEnum::Primary) { $this->object_id = array_combine($index->column, array_map(fn($e) => $this->entity->$e ?? null, $index->column)); } } } else { throw new \InvalidArgumentException("An EntityInterface must be provided using the attachEntity() method."); } } public function valid(? \Lean\Api\Entity\Security\ApiActionLog $actionLog = null): bool { return isset($this->object_id) && isset($this->object_type); } }