Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Core/Upgrade/UpgradeApiResourceVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can't be the default, indeed in API Platform 3 we recommend to put the item GET operation as first one because this is the one that identifies the Resource in the first place.

@WilliamPeralta WilliamPeralta Nov 6, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soyuka you kindly tell me how I can avoid that the route of the "itemOperation" take also the customized routes without changing the order? i get a 404 error if i put itemoperation first.

);

if (null !== $operations) {
Expand Down Expand Up @@ -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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep this patch, it's a good idea thanks!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@soyuka Great, I am very pleased to have been helpful.

}
$operations[] = $this->createOperation($this->getOperationNamespace($method, $isCollection), $operation);
}

Expand Down