Problem/motivation
This issue was openend way back and referenced in the json:api code. Since this issue is deemed outdated, the reference to the issue should be removed from core.
Remaining tasks
Remove reference to this issue from: core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php:217
Old IS
Issue title pretty much says it all, but there are certainly other clean-ups to be done in the exception classes, like these static \Drupal:: bits:
$error['links']['via']['href'] = \Drupal::request()->getUri();
and
$resource_type = \Drupal::service('jsonapi.resource_type.repository')->get($entity_type_id, $bundle);
$resource_type_name = $resource_type->getTypeName();
$route_name = !is_null($relationship_field)
? "jsonapi.$resource_type_name.$relationship_field.related"
: "jsonapi.$resource_type_name.individual";
$url = Url::fromRoute($route_name, ['entity' => $entity->uuid()]);
$errors[0]['links']['via']['href'] = $url->setAbsolute()->toString(TRUE)->getGeneratedUrl();
Comments
Comment #2
gabesulliceComment #3
gabesulliceComment #4
gabesulliceComment #5
gabesullice#3036286: Clean-up: JsonApiDocumentTopLevelNormalizer and children to prep for further clean-ups landed!
Comment #6
wim leersComment #7
wim leersComment #8
wim leersI started implementing this, but then I noticed that
\Drupal\jsonapi\Normalizer\UnprocessableHttpEntityExceptionNormalizer::buildErrorObject()in fact does generate multiple error objects :)(Yes, this has since been renamed from
::buildErrors()to::buildErrorObjects().)If you can confirm this, let's close this!
Comment #10
gabesulliceSorry for taking so long to confirm this. I didn't want to close this issue because I remember that when I created it I was really irked by some non-obvious wonkiness. Honestly, I don't remember the specifics even though I'm positive that we haven't done anything that would have addressed it—I should have been much more verbose in the issue summary.
Long story short, I'm closing this as outdated because the issue title is about
*Exception::buildErrors, which doesn't even exist anymore (it was refactored intoHttpExceptionNormalizer::buildErrorObjects()).I think the gremlins are still hiding somewhere around here, but we'll just have to open a new issue when they come out to play.
Comment #11
bbralaThis issue is referenced in the code of json:api
core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php:217. If we decided this is not an issue we should use this issue to remove the reference.Comment #14
soham sengupta commentedI have removed the reference from the code and created the MR. Moving the issue to Needs Review state.
Thank you.
Comment #15
arun.k commented@Soham Sengupta i have checked the merge request MR !8532 and found the refrence from the file core/modules/jsonapi/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php has been removed and working fine.
Step to check
1. install drupal 11.x on DDEV v1.22.6 and php 8.3.0
2. use command git remote add drupal-3036284 https://git.drupalcode.org/issue/drupal-3036284.git
3. git fetch drupal-3036284
4. git checkout -b '3036284-clean-up-exceptionbuilderrors-returns' --track drupal-3036284/'3036284-clean-up-exceptionbuilderrors-returns'
and found removed refrence from the code
Comment #16
arun.k commentedComment #17
bbralaAll good, thank you.
Comment #18
quietone commentedNot sure about this. The coding standards state
That recommends that this @todo should link to the issue where the work is being done. That helps us find the work to do, a @todo without an issue tends to be forgotten. I'd much rather this have a link to an issue.
Comment #19
bbralaYou are right, not sure how i missed that.
The change did not so as per IS, remove the whole todo.