Problem/Motivation

I'm utilising Routes::isJsonApiRequest($route_defaults) to check to see if a route is a jsonapi route, this does not return true for jsonapi resource routes I would like an equivalent to check to see if.

Steps to reproduce

Proposed resolution

In the patch I have attached a static method in Drupal\jsonapi_resources\Unstable\Routing::isJsonApiResourceRequest to provide route checking ability for a jsonapi_resource route.

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

RichardGaunt created an issue. See original summary.

mglaman’s picture

Status: Active » Needs review
mglaman’s picture

Issue tags: +Needs tests
richardgaunt’s picture

Updated patch to add unit test testing against different routes.

richardgaunt’s picture

Issue tags: -Needs tests
mglaman’s picture

Status: Needs review » Needs work

Thank you for adding a test!

+++ b/tests/src/Unit/Routing/ResourceRoutesTest.php
@@ -19,36 +20,52 @@ use Symfony\Component\Routing\RouteCollection;
+  private RouteCollection $routeCollection;

I'm guessing PhpStorm added this. We're not requiring >= 7.4 so we can't type properties.

mglaman’s picture

Parent issue: » #3428278: Release 1.0
mglaman’s picture

Status: Needs work » Needs review

Typed properties are OK now :)

mglaman’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, ready to merge!

  • mglaman committed 92fb9db1 on 8.x-1.x
    Issue #3198310 by mglaman, RichardGaunt: Add method to check if the...
mglaman’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

Status: Fixed » Closed (fixed)

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