Problem/Motivation
In an attempt to learn more about the module, I came across the following code in \Drupal\jsonapi_resources\Resource\ResourceBase:
/**
* {@inheritdoc}
*/
public function getRouteResourceTypes(Route $route, string $route_name): array {
However, ResourceBase does not extend anything so there are no docs to inherit for the getRouteResourceTypes method.
Proposed resolution
Write documentation in the method's docblock.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3200821-2.patch | 751 bytes | Pooja Ganjage |
Issue fork jsonapi_resources-3200821
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
Pooja Ganjage commentedHi,
Creating a patch for this issue.
Please review the patch.
Thanks.
Comment #3
Pooja Ganjage commentedComment #4
marcvangendThanks Pooja, that's a good start but I guess there is more to do here.
First of all, the return value could be more specific. If I'm not mistaken, the method is supposed to return an array of ResourceType objects, so the @return statement could be
@return \Drupal\jsonapi\ResourceType\ResourceType[]. (Somebody please correct me if I'm wrong, I'm only interpreting code I didn't write.)Second, the proposed docblock still doesn't explain why this method exists or how it works. The patch says "Get the route for resource types." but I'm not even sure if that's true... Did you check with the maintainers? Shouldn't it be "Returns the resource types for the route."? (In any case, according to Drupal documentation standards, the verb should be 3rd person singular, so "Gets" or "Returns".)
Finally, this method seems to read the '_jsonapi_resource_types' property of a route. I'd like to see documented how that can be used, maybe even with some example code.
Comment #5
mglamanComment #7
mglamanOPned https://git.drupalcode.org/project/jsonapi_resources/-/merge_requests/8
It's briefly described, like the exception in the code. There are examples in the tests.
Comment #8
mglamanComment #10
mglaman