Skip to content

Commit

Permalink
fix(metadata): fix Operations sort
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed Mar 7, 2024
1 parent 055fb38 commit 1c2509f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Metadata/ApiResource.php
Expand Up @@ -1018,6 +1018,7 @@ public function withOperations(Operations $operations): self
{
$self = clone $this;
$self->operations = $operations;
$self->operations->sort();

return $self;
}
Expand Down
Expand Up @@ -121,7 +121,7 @@ private function buildResourceOperations(array $attributes, string $resourceClas
[$key, $operation] = $this->getOperationWithDefaults($resources[$index], $operationAttribute);
$operation = $operation->withPriority(++$operationPriority);
$operations = $resources[$index]->getOperations() ?? new Operations();
$resources[$index] = $resources[$index]->withOperations($operations->add($key, $operation)->sort());
$resources[$index] = $resources[$index]->withOperations($operations->add($key, $operation));
}

// Loop again and set default operations if none where found
Expand Down
Expand Up @@ -52,7 +52,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
}
}

$resource = $resource->withOperations($operations->sort());
$resource = $resource->withOperations($operations);
$resourceMetadataCollection[$i] = $resource;
}

Expand Down
Expand Up @@ -56,7 +56,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
$operations->remove($operationName)->add($newOperationName, $operation->withName($newOperationName));
}

$resourceMetadataCollection[$i] = $resource->withOperations($operations->sort());
$resourceMetadataCollection[$i] = $resource->withOperations($operations);
}

return $resourceMetadataCollection;
Expand Down
Expand Up @@ -88,7 +88,7 @@ public function create(string $resourceClass): ResourceMetadataCollection
$operations->add($operation->getName(), $operation);
}

$resource = $resource->withOperations($operations->sort());
$resource = $resource->withOperations($operations);
$resourceMetadataCollection[$i] = $resource;
}

Expand Down

0 comments on commit 1c2509f

Please sign in to comment.