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.

CommentFileSizeAuthor
#2 3200821-2.patch751 bytesPooja Ganjage
Command icon 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

marcvangend created an issue. See original summary.

Pooja Ganjage’s picture

StatusFileSize
new751 bytes

Hi,

Creating a patch for this issue.

Please review the patch.

Thanks.

Pooja Ganjage’s picture

Status: Active » Needs review
marcvangend’s picture

Status: Needs review » Needs work

Thanks 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.

mglaman’s picture

Parent issue: » #3428278: Release 1.0

mglaman’s picture

Status: Needs work » Needs review

OPned https://git.drupalcode.org/project/jsonapi_resources/-/merge_requests/8

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.

It's briefly described, like the exception in the code. There are examples in the tests.

mglaman’s picture

  • mglaman committed b8fdd6ac on 8.x-1.x
    Issue #3200821 by mglaman, Pooja Ganjage: Document ResourceBase::...
mglaman’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.