Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
We want to type hint the ResourceResponseInterface
instead of ResourceResponse
, so we can use polymorphism. This was uncovered by #2747259: [BUG] strict error.
Proposed resolution
Use the interface instead of the class name.
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff-2751497-5-6.txt | 1.56 KB | gabesullice |
#7 | rest-interfaces-2751497-6.patch | 1.03 KB | gabesullice |
#5 | rest-interfaces-2751497-5.patch | 1.48 KB | gabesullice |
Comments
Comment #2
e0ipsoComment #3
gabesulliceJust discovered this. This breaks compatibility with Drupal 8.1.
Comment #4
dawehner@gabesullice
We could have a different method name than the parent class. This would allow us to not break stuff.
Comment #5
gabesulliceLooks like the
::renderResponse()
method signature got updated again. Just fixing that for now. Not addressing 8.1 compatibility.Comment #6
gabesullicekick tests.
Comment #7
gabesulliceTurns out there were far more changes in core than I realized, just going with a different method name as you suggested, @dawehner :)
Comment #9
dawehner+1
Thank you, just committed and pushed.
Comment #11
akoe CreditAttribution: akoe commentedI'm having trouble with this patch
Argument 2 passed to Drupal\jsonapi\RequestHandler::renderJsonApiResponse() must be an instance of Drupal\rest\ResourceResponseInterface, instance of Drupal\rest\ResourceResponse given, called in /var/www/html/web/modules/contrib/jsonapi/src/RequestHandler.php
Could this be related to a different core version? Im using 8.1.8 at the moment.
Comment #12
e0ipsoThe minimum supported core version is 8.2.x. Sorry for the inconvenience, you can revert this patch to try to get support on 8.1.x.
Please report back if that worked.
Comment #13
akoe CreditAttribution: akoe commented@e0ipso you were right it works fine with core 8.2.x and reverting the patch solved the issue.