Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Routes.php

function Routes::addRouteParameter

Adds a parameter option to a route, overrides options of the same name.

The Symfony Route class only has a method for adding options which overrides any previous values. Therefore, it is tedious to add a single parameter while keeping those that are already set.

Parameters

\Symfony\Component\Routing\Route $route: The route to which the parameter is to be added.

string $name: The name of the parameter.

mixed $parameter: The parameter's options.

2 calls to Routes::addRouteParameter()
Routes::getFileUploadRoutesForResourceType in core/modules/jsonapi/src/Routing/Routes.php
Gets the file upload route collection for the given resource type.
Routes::getRoutesForResourceType in core/modules/jsonapi/src/Routing/Routes.php
Gets applicable resource routes for a JSON:API resource type.

File

core/modules/jsonapi/src/Routing/Routes.php, line 388

Class

Routes
Defines dynamic routes.

Namespace

Drupal\jsonapi\Routing

Code

protected static function addRouteParameter(Route $route, $name, $parameter) {
    $parameters = $route->getOption('parameters') ?: [];
    $parameters[$name] = $parameter;
    $route->setOption('parameters', $parameters);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal