You are here

public function PhpMatcherDumper::dump in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php \Symfony\Component\Routing\Matcher\Dumper\PhpMatcherDumper::dump()

Dumps a set of routes to a PHP class.

Available options:

  • class: The class name
  • base_class: The base class name

Parameters

array $options An array of options:

Return value

string A PHP class representing the matcher class

Overrides MatcherDumperInterface::dump

File

vendor/symfony/routing/Matcher/Dumper/PhpMatcherDumper.php, line 47

Class

PhpMatcherDumper
PhpMatcherDumper creates a PHP class able to match URLs for a given set of routes.

Namespace

Symfony\Component\Routing\Matcher\Dumper

Code

public function dump(array $options = array()) {
  $options = array_replace(array(
    'class' => 'ProjectUrlMatcher',
    'base_class' => 'Symfony\\Component\\Routing\\Matcher\\UrlMatcher',
  ), $options);

  // trailing slash support is only enabled if we know how to redirect the user
  $interfaces = class_implements($options['base_class']);
  $supportsRedirections = isset($interfaces['Symfony\\Component\\Routing\\Matcher\\RedirectableUrlMatcherInterface']);
  return <<<EOF
<?php

use Symfony\\Component\\Routing\\Exception\\MethodNotAllowedException;
use Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException;
use Symfony\\Component\\Routing\\RequestContext;

/**
 * {<span class="php-variable">$options</span>[<span class="php-string">'class'</span>]}.
 *
 * This class has been auto-generated
 * by the Symfony Routing Component.
 */
class {<span class="php-variable">$options</span>[<span class="php-string">'class'</span>]} extends {<span class="php-variable">$options</span>[<span class="php-string">'base_class'</span>]}
{
    /**
     * Constructor.
     */
    public function __construct(RequestContext \$context)
    {
        \$this->context = \$context;
    }

{<span class="php-variable">$this</span>
  -&gt;<span class="php-function-or-constant function member-of-self">generateMatchMethod</span>(<span class="php-variable">$supportsRedirections</span>)}
}

EOF;
}