Resolve document before default in the argument_resolver service
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3094907. --> Reported by: [sam711](https://www.drupal.org/user/3561059) >>> <p>The public process method on the classes extending the ResourceBase can have different definitions depending on the request method. When trying to handle GET and POST on the same route with:</p> <p><code>methods: ['GET', 'POST']</code></p> <p>I need:</p> <p>GET:<br> <code>public function process(Request $request): ResourceResponse</code></p> <p>POST:<br> <code>public function process(Request $request, JsonApiDocumentTopLevel $document): ResourceResponse</code></p> <p>Because the arguments depend on the process definition:</p> <pre>$args = $this-&gt;argumentResolver-&gt;getArguments($request, [$resource, 'process']);<br>$response = $resource-&gt;process(...$args);</pre><p>I can't make both methods work with an unique definition of the process function. Adding a default NULL value on the $document doesn't work on POST either.</p> <p>I could create a custom _controller and handle the logic depending on the request method or have one separated route per method. But I think this could be a common enough use case to be supported within the module.</p> <p>Is there a different approach? Am I missing something?</p> <p>What do you think?<br> Thanks.</p> > Related issue: [Issue #3094974](https://www.drupal.org/node/3094974) > Related issue: [Issue #3096424](https://www.drupal.org/node/3096424)
issue