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

Breadcrumb

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

function Router::setOptions

Sets options.

Available options:

  • cache_dir: The cache directory (or null to disable caching)
  • debug: Whether to enable debugging or not (false by default)
  • generator_class: The name of a UrlGeneratorInterface implementation
  • generator_dumper_class: The name of a GeneratorDumperInterface implementation
  • matcher_class: The name of a UrlMatcherInterface implementation
  • matcher_dumper_class: The name of a MatcherDumperInterface implementation
  • resource_type: Type hint for the main resource (optional)
  • strict_requirements: Configure strict requirement checking for generators implementing ConfigurableRequirementsInterface (default is true)

Throws

\InvalidArgumentException When unsupported option is provided

1 call to Router::setOptions()
Router::__construct in vendor/symfony/routing/Router.php

File

vendor/symfony/routing/Router.php, line 84

Class

Router
The Router class is an example of the integration of all pieces of the routing system for easier use.

Namespace

Symfony\Component\Routing

Code

public function setOptions(array $options) : void {
    $this->options = [
        'cache_dir' => null,
        'debug' => false,
        'generator_class' => CompiledUrlGenerator::class,
        'generator_dumper_class' => CompiledUrlGeneratorDumper::class,
        'matcher_class' => CompiledUrlMatcher::class,
        'matcher_dumper_class' => CompiledUrlMatcherDumper::class,
        'resource_type' => null,
        'strict_requirements' => true,
    ];
    // check option names and live merge, if errors are encountered Exception will be thrown
    $invalid = [];
    foreach ($options as $key => $value) {
        if (\array_key_exists($key, $this->options)) {
            $this->options[$key] = $value;
        }
        else {
            $invalid[] = $key;
        }
    }
    if ($invalid) {
        throw new \InvalidArgumentException(\sprintf('The Router does not support the following options: "%s".', implode('", "', $invalid)));
    }
}

API Navigation

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