Skip to content

Commit b99639e

Browse files
committed
Fixed the positions update for Amv and Objects compositions.
1 parent 5065834 commit b99639e

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

src/Controller/ApiAnrObjectsObjectsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function update($id, $data)
5555

5656
$this->anrObjectObjectService->shiftPositionInComposition(
5757
$anr,
58-
$id,
58+
(int)$id,
5959
$this->movePositionDataInputValidator->getValidData()
6060
);
6161

src/Entity/Amv.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,13 @@ class Amv extends AmvSuperClass
7676

7777
public function getImplicitPositionRelationsValues(): array
7878
{
79-
return array_merge(['anr' => $this->anr], parent::getImplicitPositionRelationsValues());
79+
return [
80+
'anr' => $this->anr,
81+
'asset' => [
82+
'uuid' => $this->asset->getUuid(),
83+
'anr' => $this->anr,
84+
]
85+
];
8086
}
8187

8288
public function getAnr(): Anr

src/Entity/ObjectObject.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@ class ObjectObject extends ObjectObjectSuperClass
5454

5555
public function getImplicitPositionRelationsValues(): array
5656
{
57-
return array_merge(['anr' => $this->anr], parent::getImplicitPositionRelationsValues());
57+
return [
58+
'anr' => $this->anr,
59+
'parent' => [
60+
'uuid' => $this->parent->getUuid(),
61+
'anr' => $this->anr,
62+
]
63+
];
5864
}
5965

6066
public function setAnr(Anr $anr): self

src/Service/AnrObjectObjectService.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ public function create(Entity\Anr $anr, array $data, bool $saveInDb = true): Ent
4141
}
4242

4343
/** @var Entity\MonarcObject $parentObject */
44-
$parentObject = $this->monarcObjectTable->findByIdAndAnr($data['parent'], $anr);
44+
$parentObject = $this->monarcObjectTable->findByUuidAndAnr($data['parent'], $anr);
4545
/** @var Entity\MonarcObject $childObject */
46-
$childObject = $this->monarcObjectTable->findByIdAndAnr($data['child'], $anr);
46+
$childObject = $this->monarcObjectTable->findByUuidAndAnr($data['child'], $anr);
4747
if ($parentObject->hasChild($childObject)) {
4848
throw new Exception('The object is already presented in the composition.', 412);
4949
}
@@ -101,9 +101,16 @@ public function shiftPositionInComposition(Entity\Anr $anr, int $id, array $data
101101
);
102102
/* Some positions are not aligned in the DB, that's why we may have empty result. */
103103
if ($previousObjectCompositionLink !== null) {
104-
$this->objectObjectTable->save($previousObjectCompositionLink->setPosition($objectObject->getPosition()));
104+
$this->objectObjectTable->save(
105+
$previousObjectCompositionLink->setPosition($objectObject->getPosition())->setUpdater(
106+
$this->connectedUser->getEmail()
107+
),
108+
false
109+
);
105110
}
106-
$this->objectObjectTable->save($objectObject->setPosition($positionToBeSet));
111+
$this->objectObjectTable->save(
112+
$objectObject->setPosition($positionToBeSet)->setUpdater($this->connectedUser->getEmail())
113+
);
107114
}
108115

109116
public function delete(Entity\Anr $anr, int $id): void

src/Service/AnrObjectService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getList(FormattedInputParams $formattedInputParams): array
5151

5252
public function getCount(FormattedInputParams $formattedInputParams): int
5353
{
54-
return $this->monarcObjectTable->countByParams($formattedInputParams);
54+
return $this->monarcObjectTable->countByParams($formattedInputParams, 'uuid');
5555
}
5656

5757
public function getObjectData(Entity\Anr $anr, string $uuid, FormattedInputParams $formattedInputParams): array

0 commit comments

Comments
 (0)