Skip to content

Commit

Permalink
fix(Contexts): also update node permissions
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
  • Loading branch information
blizzz authored and enjeck committed Apr 19, 2024
1 parent b834bbb commit 9eff365
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/Service/ContextService.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,15 @@ public function update(int $contextId, string $userId, ?string $name, ?string $i
foreach ($nodes as $node) {
$key = sprintf('t%di%d', $node['type'], $node['id']);
if (isset($oldNodeResolvableIdMapper[$key])) {
unset($oldNodeResolvableIdMapper[$key]);
$nodesBeingKept[$key] = $node;
if ($node['permissions'] !== $currentNodes[$oldNodeResolvableIdMapper[$key]]['permissions']) {
$nodeRel = $this->contextNodeRelMapper->findById($currentNodes[$oldNodeResolvableIdMapper[$key]]['id']);
$nodeRel->setPermissions($node['permissions']);
$this->contextNodeRelMapper->update($nodeRel);
$currentNodes[$oldNodeResolvableIdMapper[$key]]['permissions'] = $nodeRel->getPermissions();
$hasUpdatedNodeInformation = true;
}
unset($oldNodeResolvableIdMapper[$key]);
continue;
}
$nodesBeingAdded[$key] = $node;
Expand All @@ -172,7 +179,7 @@ public function update(int $contextId, string $userId, ?string $name, ?string $i
}
unset($nodesBeingKept);

$hasUpdatedNodeInformation = !empty($nodesBeingAdded) || !empty($nodesBeingRemoved);
$hasUpdatedNodeInformation = $hasUpdatedNodeInformation || !empty($nodesBeingAdded) || !empty($nodesBeingRemoved);

foreach ($nodesBeingRemoved as $node) {
/** @var ContextNodeRelation $removedNode */
Expand Down Expand Up @@ -203,10 +210,11 @@ public function update(int $contextId, string $userId, ?string $name, ?string $i
}

$context = $this->contextMapper->update($context);
if ($hasUpdatedNodeInformation && isset($currentNodes) && isset($currentPages)) {
if (isset($currentNodes, $currentPages) && $hasUpdatedNodeInformation) {
$context->setNodes($currentNodes);
$context->setPages($currentPages);
}

return $context;
}

Expand Down

0 comments on commit 9eff365

Please sign in to comment.