From d6fcf73723dd6fea63acdd8db1bd30ccc1f152bd Mon Sep 17 00:00:00 2001 From: WilliamPeralta Date: Mon, 31 Oct 2022 13:18:50 +0100 Subject: [PATCH] fixed registration of routes order and added operation name I have adjusted the order of the registration of the routes to avoid that itemOperations conflict with collection operation. For instance: ``` api/books/avaliable api/books/{id} ``` instead of ``` api/books/{id} api/books/avaliable ``` I also added the name of the operation that I use a lot in the "doctrine extension" and they are not there anymore than after the migration --- src/Core/Upgrade/UpgradeApiResourceVisitor.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Core/Upgrade/UpgradeApiResourceVisitor.php b/src/Core/Upgrade/UpgradeApiResourceVisitor.php index ead9a207f01..ab50460824b 100644 --- a/src/Core/Upgrade/UpgradeApiResourceVisitor.php +++ b/src/Core/Upgrade/UpgradeApiResourceVisitor.php @@ -130,8 +130,8 @@ public function enterNode(Node $node) $arguments = []; $operations = null === $this->resourceAnnotation->itemOperations && null === $this->resourceAnnotation->collectionOperations ? null : array_merge( - $this->legacyOperationsToOperations($this->getLegacyOperations()), - $this->legacyOperationsToOperations($this->getLegacyOperations(true), true) + $this->legacyOperationsToOperations($this->getLegacyOperations(true), true), + $this->legacyOperationsToOperations($this->getLegacyOperations()) ); if (null !== $operations) { @@ -443,6 +443,9 @@ private function legacyOperationsToOperations($legacyOperations, bool $isCollect $method = $operation['method'] ?? strtoupper($operationName); unset($operation['method']); + if(!in_array($operationName, ['get', 'post', 'put', 'patch', 'delete'])) { + $operation['name']= $operationName; + } $operations[] = $this->createOperation($this->getOperationNamespace($method, $isCollection), $operation); }