Move into nested docroot
This commit is contained in:
parent
83a0d3a149
commit
c8b70abde9
13405 changed files with 0 additions and 0 deletions
web/vendor/symfony-cmf/routing
98
web/vendor/symfony-cmf/routing/ProviderBasedGenerator.php
vendored
Normal file
98
web/vendor/symfony-cmf/routing/ProviderBasedGenerator.php
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Cmf\Component\Routing;
|
||||
|
||||
use Symfony\Component\Routing\Generator\UrlGenerator;
|
||||
use Symfony\Component\Routing\Route as SymfonyRoute;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* A Generator that uses a RouteProvider rather than a RouteCollection.
|
||||
*
|
||||
* @author Larry Garfield
|
||||
*/
|
||||
class ProviderBasedGenerator extends UrlGenerator implements VersatileGeneratorInterface
|
||||
{
|
||||
/**
|
||||
* The route provider for this generator.
|
||||
*
|
||||
* @var RouteProviderInterface
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @param RouteProviderInterface $provider
|
||||
* @param LoggerInterface $logger
|
||||
*/
|
||||
public function __construct(RouteProviderInterface $provider, LoggerInterface $logger = null)
|
||||
{
|
||||
$this->provider = $provider;
|
||||
$this->logger = $logger;
|
||||
$this->context = new RequestContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
|
||||
{
|
||||
if ($name instanceof SymfonyRoute) {
|
||||
$route = $name;
|
||||
} elseif (null === $route = $this->provider->getRouteByName($name)) {
|
||||
throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
// the Route has a cache of its own and is not recompiled as long as it does not get modified
|
||||
$compiledRoute = $route->compile();
|
||||
$hostTokens = $compiledRoute->getHostTokens();
|
||||
|
||||
$debug_message = $this->getRouteDebugMessage($name);
|
||||
|
||||
return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $debug_message, $referenceType, $hostTokens);
|
||||
}
|
||||
|
||||
/**
|
||||
* Support a route object and any string as route name.
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports($name)
|
||||
{
|
||||
return is_string($name) || $name instanceof SymfonyRoute;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteDebugMessage($name, array $parameters = array())
|
||||
{
|
||||
if (is_scalar($name)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if (is_array($name)) {
|
||||
return serialize($name);
|
||||
}
|
||||
|
||||
if ($name instanceof RouteObjectInterface) {
|
||||
return 'Route with key '.$name->getRouteKey();
|
||||
}
|
||||
|
||||
if ($name instanceof SymfonyRoute) {
|
||||
return 'Route with path '.$name->getPath();
|
||||
}
|
||||
|
||||
return get_class($name);
|
||||
}
|
||||
}
|
Reference in a new issue