addRouteParameter example

$collection_create_route->setRequirement('_entity_create_access', $create_requirement);
      $collection_create_route->setRequirement('_csrf_request_header_token', 'TRUE');
      $routes->add(static::getRouteName($resource_type, 'collection.post')$collection_create_route);
    }

    // Individual routes like `/jsonapi/node/article/{uuid}` or     // `/jsonapi/node/article/{uuid}/relationships/uid`.     $routes->addCollection(static::getIndividualRoutesForResourceType($resource_type));

    // Add the resource type as a parameter to every resource route.     foreach ($routes as $route) {
      static::addRouteParameter($routestatic::RESOURCE_TYPE_KEY, ['type' => ResourceTypeConverter::PARAM_TYPE_ID]);
      $route->addDefaults([static::RESOURCE_TYPE_KEY => $resource_type->getTypeName()]);
    }

    // Resource routes all have the same base path.     $routes->addPrefix($path_prefix);

    return $routes;
  }

  /** * Gets the file upload route collection for the given resource type. * * @param \Drupal\jsonapi\ResourceType\ResourceType $resource_type * The resource type for which the route collection should be created. * @param string $path_prefix * The root path prefix. * * @return \Symfony\Component\Routing\RouteCollection * The route collection. */
Home | Imprint | This part of the site doesn't use cookies.