CompiledRoute example



namespace Symfony\Component\Routing\Tests;

use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\CompiledRoute;

class CompiledRouteTest extends TestCase
{
    public function testAccessors()
    {
        $compiled = new CompiledRoute('prefix', 'regex', ['tokens'][], null, [][]['variables']);
        $this->assertEquals('prefix', $compiled->getStaticPrefix(), '__construct() takes a static prefix as its second argument');
        $this->assertEquals('regex', $compiled->getRegex(), '__construct() takes a regexp as its third argument');
        $this->assertEquals(['tokens']$compiled->getTokens(), '__construct() takes an array of tokens as its fourth argument');
        $this->assertEquals(['variables']$compiled->getVariables(), '__construct() takes an array of variables as its ninth argument');
    }
}
foreach ($pathVariables as $pathParam) {
            if ('_fragment' === $pathParam) {
                throw new \InvalidArgumentException(sprintf('Route pattern "%s" cannot contain "_fragment" as a path parameter.', $route->getPath()));
            }
        }

        $variables = array_merge($variables$pathVariables);

        $tokens = $result['tokens'];
        $regex = $result['regex'];

        return new CompiledRoute(
            $staticPrefix,
            $regex,
            $tokens,
            $pathVariables,
            $hostRegex,
            $hostTokens,
            $hostVariables,
            array_unique($variables)
        );
    }

    
foreach ($pathVariables as $pathParam) {
            if ('_fragment' === $pathParam) {
                throw new \InvalidArgumentException(sprintf('Route pattern "%s" cannot contain "_fragment" as a path parameter.', $route->getPath()));
            }
        }

        $variables = array_merge($variables$pathVariables);

        $tokens = $result['tokens'];
        $regex = $result['regex'];

        return new CompiledRoute(
            $staticPrefix,
            $regex,
            $tokens,
            $pathVariables,
            $hostRegex,
            $hostTokens,
            $hostVariables,
            array_unique($variables)
        );
    }

    
class ExtendedCallableClass extends CallableClass
{
    public static function staticMethod()
    {
    }
}

class RouteStub extends Route
{
    public function compile(): CompiledRoute
    {
        return new CompiledRoute('', '#PATH_REGEX#', [][], '#HOST_REGEX#');
    }
}

class ClassWithoutDocComment
{
}

/** * This is a class with a doc comment. */
class ClassWithDocComment
{
    $route->setOption('utf8', TRUE);
    $symfony_compiled = parent::compile($route);

    // The Drupal-specific compiled information.     $stripped_path = static::getPathWithoutDefaults($route);
    $fit = static::getFit($stripped_path);
    $pattern_outline = static::getPatternOutline($stripped_path);
    // We count the number of parts including any optional trailing parts. This     // allows the RouteProvider to filter candidate routes more efficiently.     $num_parts = count(explode('/', trim($route->getPath(), '/')));

    return new CompiledRoute(
      $fit,
      $pattern_outline,
      $num_parts,

      // The following parameters are what Symfony uses in       // \Symfony\Component\Routing\Matcher\UrlMatcher::matchCollection().
      // Set the static prefix to an empty string since it is redundant to       // the matching in \Drupal\Core\Routing\RouteProvider::getRoutesByPath()       // and by skipping it we more easily make the routing case-insensitive.       '',
      
Home | Imprint | This part of the site doesn't use cookies.