- WIP on Cronard tasks
- Added some minors features to the API web interface
This commit is contained in:
1 parent
2d560a0857
commit
a54930b6c6
10 files changed
+105
-31
No files matched your search
@@ -5,6 +5,7 @@ namespace Lean\Api\Form\Security;
|
||||
use CSSLSJ\TransportScolaire\Api\{Entity};
|
||||
use Lean\Api\Attribute\ContextField;
|
||||
use Lean\Api\Lib\FormContext;
|
||||
use Ulmus\Attribute\IndexTypeEnum;
|
||||
use Ulmus\Entity\EntityInterface;
|
||||
use Ulmus\Event\Entity\DatasetFill;
|
||||
use Ulmus\Ulmus;
|
||||
@@ -21,7 +22,7 @@ class ActionLogContext extends FormContext
|
||||
public string $method;
|
||||
|
||||
#[ContextField(mandatory: true)]
|
||||
public int $object_id;
|
||||
public int|array $object_id;
|
||||
|
||||
#[ContextField(mandatory: true)]
|
||||
public string $object_type;
|
||||
@@ -60,14 +61,24 @@ class ActionLogContext extends FormContext
|
||||
public function initializeEntity(\Lean\Api\Entity\Security\ApiActionLog $actionLog) : void
|
||||
{
|
||||
if (isset($this->entity) && $this->entity->isLoaded()) {
|
||||
if ($pk = array_key_first($this->entity::resolveEntity()->getPrimaryKeyField())) {
|
||||
$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;
|
||||
$this->object_type = $this->entity::class;
|
||||
|
||||
if (isset($this->datasetFillEvent->data)) {
|
||||
$this->data = $this->datasetFillEvent->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user