public 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)
  • resource_type: Type hint for the main resource (optional)

Parameters

array $options An array of options:

Throws

\InvalidArgumentException When unsupported option is provided

1 call to Router::setOptions()
Router::__construct in drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php
Constructor.

File

drupal/core/vendor/symfony/routing/Symfony/Component/Routing/Router.php, line 67

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) {
  $this->options = array(
    'cache_dir' => null,
    'debug' => false,
    'generator_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
    'generator_base_class' => 'Symfony\\Component\\Routing\\Generator\\UrlGenerator',
    'generator_dumper_class' => 'Symfony\\Component\\Routing\\Generator\\Dumper\\PhpGeneratorDumper',
    'generator_cache_class' => 'ProjectUrlGenerator',
    'matcher_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
    'matcher_base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
    'matcher_dumper_class' => 'Symfony\\Component\\Routing\\Matcher\\Dumper\\PhpMatcherDumper',
    'matcher_cache_class' => 'ProjectUrlMatcher',
    'resource_type' => null,
    'strict_requirements' => true,
  );

  // check option names and live merge, if errors are encountered Exception will be thrown
  $invalid = array();
  $isInvalid = false;
  foreach ($options as $key => $value) {
    if (array_key_exists($key, $this->options)) {
      $this->options[$key] = $value;
    }
    else {
      $isInvalid = true;
      $invalid[] = $key;
    }
  }
  if ($isInvalid) {
    throw new \InvalidArgumentException(sprintf('The Router does not support the following options: "%s".', implode('\', \'', $invalid)));
  }
}