Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0
This commit is contained in:
parent
2f563ab520
commit
f1c8716f57
1732 changed files with 52334 additions and 11780 deletions
1
vendor/symfony-cmf/routing/.styleci.yml
vendored
Normal file
1
vendor/symfony-cmf/routing/.styleci.yml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
preset: symfony
|
37
vendor/symfony-cmf/routing/.travis.yml
vendored
37
vendor/symfony-cmf/routing/.travis.yml
vendored
|
@ -5,26 +5,41 @@ php:
|
|||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- hhvm
|
||||
|
||||
env:
|
||||
- SYMFONY_VERSION=2.5.*
|
||||
sudo: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.composer/cache/files
|
||||
|
||||
env: SYMFONY_VERSION=2.8.*
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: hhvm
|
||||
include:
|
||||
- php: 5.5
|
||||
- php: 5.6
|
||||
env: DEPS=dev
|
||||
- php: 5.3
|
||||
env: COMPOSER_FLAGS="--prefer-lowest"
|
||||
- php: 5.6
|
||||
env: SYMFONY_VERSION=2.3.*
|
||||
- php: 5.5
|
||||
env: SYMFONY_VERSION=2.4.*
|
||||
- php: 5.5
|
||||
env: SYMFONY_VERSION=2.*
|
||||
- php: 5.6
|
||||
env: SYMFONY_VERSION=2.7.*
|
||||
- php: 5.6
|
||||
env: SYMFONY_VERSION=3.0.*
|
||||
finish_fast: true
|
||||
|
||||
before_install:
|
||||
- composer require symfony/routing:${SYMFONY_VERSION} --prefer-source
|
||||
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi
|
||||
- phpenv config-rm xdebug.ini || true
|
||||
- composer self-update
|
||||
- if [ "$DEPS" = "dev" ]; then perl -pi -e 's/^}$/,"minimum-stability":"dev"}/' composer.json; fi
|
||||
- if [ "$SYMFONY_VERSION" != "" ]; then composer require symfony/symfony:${SYMFONY_VERSION} --no-update; fi
|
||||
|
||||
install: composer update --prefer-dist $COMPOSER_FLAGS
|
||||
|
||||
script: phpunit --coverage-text
|
||||
script: phpunit
|
||||
|
||||
notifications:
|
||||
irc: "irc.freenode.org#symfony-cmf"
|
||||
|
|
18
vendor/symfony-cmf/routing/CHANGELOG.md
vendored
18
vendor/symfony-cmf/routing/CHANGELOG.md
vendored
|
@ -1,11 +1,29 @@
|
|||
Changelog
|
||||
=========
|
||||
|
||||
1.4.0
|
||||
-----
|
||||
|
||||
* **2016-02-27**: Added ContentRepositoryEnhancer that can look up a content by
|
||||
ID from a content repository.
|
||||
|
||||
1.4.0-RC1
|
||||
---------
|
||||
|
||||
* **2016-01-09**: When ChainRouter::match is used with a RequestMatcher, the
|
||||
Request is now properly rebuilt from the RequestContext if that was set on
|
||||
the ChainRouter, and http://localhost is used otherwise to avoid issues with
|
||||
paths starting with a double forward slash.
|
||||
* **2014-09-29**: ChainRouter does not require a RouterInterface, as a
|
||||
RequestMatcher and UrlGenerator is fine too. Fixed chain router interface to
|
||||
not force a RouterInterface.
|
||||
* **2014-09-29**: Deprecated DynamicRouter::match in favor of matchRequest.
|
||||
|
||||
1.3.0
|
||||
-----
|
||||
|
||||
Release 1.3.0
|
||||
|
||||
1.3.0-RC1
|
||||
---------
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -60,7 +60,7 @@ class Candidates implements CandidatesInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Always returns true.
|
||||
*/
|
||||
|
@ -70,7 +70,7 @@ class Candidates implements CandidatesInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Does nothing.
|
||||
*/
|
||||
|
@ -79,7 +79,7 @@ class Candidates implements CandidatesInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCandidates(Request $request)
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ class Candidates implements CandidatesInterface
|
|||
*
|
||||
* @param string $url The url to determine the locale from.
|
||||
*
|
||||
* @return string|boolean The locale if $url starts with one of the allowed locales.
|
||||
* @return string|bool The locale if $url starts with one of the allowed locales.
|
||||
*/
|
||||
protected function determineLocale($url)
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ class Candidates implements CandidatesInterface
|
|||
}
|
||||
|
||||
$matches = array();
|
||||
if (preg_match('#(' . implode('|', $this->locales) . ')(/|$)#', $url, $matches)) {
|
||||
if (preg_match('#('.implode('|', $this->locales).')(/|$)#', $url, $matches)) {
|
||||
return $matches[1];
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ class Candidates implements CandidatesInterface
|
|||
if ('/' !== $url) {
|
||||
// handle format extension, like .html or .json
|
||||
if (preg_match('/(.+)\.[a-z]+$/i', $url, $matches)) {
|
||||
$candidates[] = $prefix . $url;
|
||||
$candidates[] = $prefix.$url;
|
||||
$url = $matches[1];
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ class Candidates implements CandidatesInterface
|
|||
if (++$count > $this->limit) {
|
||||
return $candidates;
|
||||
}
|
||||
$candidates[] = $prefix . $part;
|
||||
$candidates[] = $prefix.$part;
|
||||
$part = substr($url, 0, $pos);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -33,7 +33,7 @@ interface CandidatesInterface
|
|||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isCandidate($name);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -57,7 +57,7 @@ class ChainRouteCollection extends RouteCollection
|
|||
{
|
||||
$count = 0;
|
||||
foreach ($this->routeCollections as $routeCollection) {
|
||||
$count+= $routeCollection->count();
|
||||
$count += $routeCollection->count();
|
||||
}
|
||||
|
||||
return $count;
|
||||
|
@ -106,11 +106,11 @@ class ChainRouteCollection extends RouteCollection
|
|||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a route or an array of routes by name from the collection
|
||||
* Removes a route or an array of routes by name from the collection.
|
||||
*
|
||||
* @param string|array $name The route name or an array of route names
|
||||
*/
|
||||
|
|
69
vendor/symfony-cmf/routing/ChainRouter.php
vendored
69
vendor/symfony-cmf/routing/ChainRouter.php
vendored
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -38,7 +38,8 @@ class ChainRouter implements ChainRouterInterface, WarmableInterface
|
|||
private $context;
|
||||
|
||||
/**
|
||||
* Array of arrays of routers grouped by priority
|
||||
* Array of arrays of routers grouped by priority.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $routers = array();
|
||||
|
@ -117,7 +118,7 @@ class ChainRouter implements ChainRouterInterface, WarmableInterface
|
|||
|
||||
/**
|
||||
* Sort routers by priority.
|
||||
* The highest priority number is the highest priority (reverse sorting)
|
||||
* The highest priority number is the highest priority (reverse sorting).
|
||||
*
|
||||
* @return RouterInterface[]
|
||||
*/
|
||||
|
@ -140,9 +141,9 @@ class ChainRouter implements ChainRouterInterface, WarmableInterface
|
|||
*
|
||||
* Note: You should use matchRequest if you can.
|
||||
*/
|
||||
public function match($url)
|
||||
public function match($pathinfo)
|
||||
{
|
||||
return $this->doMatch($url);
|
||||
return $this->doMatch($pathinfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -161,14 +162,14 @@ class ChainRouter implements ChainRouterInterface, WarmableInterface
|
|||
* At least the url must be provided, if a request is additionally provided
|
||||
* the request takes precedence.
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $pathinfo
|
||||
* @param Request $request
|
||||
*
|
||||
* @return array An array of parameters
|
||||
*
|
||||
* @throws ResourceNotFoundException If no router matched.
|
||||
*/
|
||||
private function doMatch($url, Request $request = null)
|
||||
private function doMatch($pathinfo, Request $request = null)
|
||||
{
|
||||
$methodNotAllowed = null;
|
||||
|
||||
|
@ -179,13 +180,14 @@ class ChainRouter implements ChainRouterInterface, WarmableInterface
|
|||
// matching requests is more powerful than matching URLs only, so try that first
|
||||
if ($router instanceof RequestMatcherInterface) {
|
||||
if (empty($requestForMatching)) {
|
||||
$requestForMatching = Request::create($url);
|
||||
$requestForMatching = $this->rebuildRequest($pathinfo);
|
||||
}
|
||||
|
||||
return $router->matchRequest($requestForMatching);
|
||||
}
|
||||
|
||||
// every router implements the match method
|
||||
return $router->match($url);
|
||||
return $router->match($pathinfo);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
if ($this->logger) {
|
||||
$this->logger->debug('Router '.get_class($router).' was not able to match, message "'.$e->getMessage().'"');
|
||||
|
@ -201,7 +203,7 @@ class ChainRouter implements ChainRouterInterface, WarmableInterface
|
|||
|
||||
$info = $request
|
||||
? "this request\n$request"
|
||||
: "url '$url'";
|
||||
: "url '$pathinfo'";
|
||||
throw $methodNotAllowed ?: new ResourceNotFoundException("None of the routers in the chain matched $info");
|
||||
}
|
||||
|
||||
|
@ -211,7 +213,7 @@ class ChainRouter implements ChainRouterInterface, WarmableInterface
|
|||
* Loops through all registered routers and returns a router if one is found.
|
||||
* It will always return the first route generated.
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $absolute = false)
|
||||
public function generate($name, $parameters = array(), $absolute = UrlGeneratorInterface::ABSOLUTE_PATH)
|
||||
{
|
||||
$debug = array();
|
||||
|
||||
|
@ -248,6 +250,41 @@ class ChainRouter implements ChainRouterInterface, WarmableInterface
|
|||
throw new RouteNotFoundException(sprintf('None of the chained routers were able to generate route: %s', $info));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuild the request object from a URL with the help of the RequestContext.
|
||||
*
|
||||
* If the request context is not set, this simply returns the request object built from $uri.
|
||||
*
|
||||
* @param string $pathinfo
|
||||
*
|
||||
* @return Request
|
||||
*/
|
||||
private function rebuildRequest($pathinfo)
|
||||
{
|
||||
if (!$this->context) {
|
||||
return Request::create('http://localhost'.$pathinfo);
|
||||
}
|
||||
|
||||
$uri = $pathinfo;
|
||||
|
||||
$server = array();
|
||||
if ($this->context->getBaseUrl()) {
|
||||
$uri = $this->context->getBaseUrl().$pathinfo;
|
||||
$server['SCRIPT_FILENAME'] = $this->context->getBaseUrl();
|
||||
$server['PHP_SELF'] = $this->context->getBaseUrl();
|
||||
}
|
||||
$host = $this->context->getHost() ?: 'localhost';
|
||||
if ('https' === $this->context->getScheme() && 443 !== $this->context->getHttpsPort()) {
|
||||
$host .= ':'.$this->context->getHttpsPort();
|
||||
}
|
||||
if ('http' === $this->context->getScheme() && 80 !== $this->context->getHttpPort()) {
|
||||
$host .= ':'.$this->context->getHttpPort();
|
||||
}
|
||||
$uri = $this->context->getScheme().'://'.$host.$uri.'?'.$this->context->getQueryString();
|
||||
|
||||
return Request::create($uri, $this->context->getMethod(), $this->context->getParameters(), array(), array(), $server);
|
||||
}
|
||||
|
||||
private function getErrorMessage($name, $router = null, $parameters = null)
|
||||
{
|
||||
if ($router instanceof VersatileGeneratorInterface) {
|
||||
|
@ -306,4 +343,14 @@ class ChainRouter implements ChainRouterInterface, WarmableInterface
|
|||
|
||||
return $this->routeCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify if any routers have been added into the chain yet.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRouters()
|
||||
{
|
||||
return !empty($this->routers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -26,7 +26,7 @@ interface ChainRouterInterface extends RouterInterface, RequestMatcherInterface
|
|||
*
|
||||
* @param RouterInterface $router The router instance. Instead of RouterInterface, may also
|
||||
* be RequestMatcherInterface and UrlGeneratorInterface.
|
||||
* @param integer $priority The priority
|
||||
* @param int $priority The priority
|
||||
*/
|
||||
public function add($router, $priority = 0);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -12,6 +12,7 @@
|
|||
namespace Symfony\Cmf\Component\Routing;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Routing\Route as SymfonyRoute;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
@ -36,16 +37,16 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
|
||||
/**
|
||||
* The content repository used to find content by it's id
|
||||
* This can be used to specify a parameter content_id when generating urls
|
||||
* This can be used to specify a parameter content_id when generating urls.
|
||||
*
|
||||
* This is optional and might not be initialized.
|
||||
*
|
||||
* @var ContentRepositoryInterface
|
||||
* @var ContentRepositoryInterface
|
||||
*/
|
||||
protected $contentRepository;
|
||||
|
||||
/**
|
||||
* Set an optional content repository to find content by ids
|
||||
* Set an optional content repository to find content by ids.
|
||||
*
|
||||
* @param ContentRepositoryInterface $contentRepository
|
||||
*/
|
||||
|
@ -55,7 +56,7 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param string $name ignored.
|
||||
* @param array $parameters must either contain the field 'route' with a
|
||||
|
@ -65,7 +66,7 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
*
|
||||
* @throws RouteNotFoundException If there is no such route in the database
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $absolute = false)
|
||||
public function generate($name, $parameters = array(), $absolute = UrlGeneratorInterface::ABSOLUTE_PATH)
|
||||
{
|
||||
if ($name instanceof SymfonyRoute) {
|
||||
$route = $this->getBestLocaleRoute($name, $parameters);
|
||||
|
@ -75,7 +76,7 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
$route = $this->getRouteByContent($name, $parameters);
|
||||
}
|
||||
|
||||
if (! $route instanceof SymfonyRoute) {
|
||||
if (!$route instanceof SymfonyRoute) {
|
||||
$hint = is_object($route) ? get_class($route) : gettype($route);
|
||||
throw new RouteNotFoundException('Route of this document is not an instance of Symfony\Component\Routing\Route but: '.$hint);
|
||||
}
|
||||
|
@ -86,7 +87,7 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the route by a string name
|
||||
* Get the route by a string name.
|
||||
*
|
||||
* @param string $route
|
||||
* @param array $parameters
|
||||
|
@ -99,7 +100,7 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
{
|
||||
$route = $this->provider->getRouteByName($name);
|
||||
if (empty($route)) {
|
||||
throw new RouteNotFoundException('No route found for name: ' . $name);
|
||||
throw new RouteNotFoundException('No route found for name: '.$name);
|
||||
}
|
||||
|
||||
return $this->getBestLocaleRoute($route, $parameters);
|
||||
|
@ -116,12 +117,12 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
*/
|
||||
protected function getBestLocaleRoute(SymfonyRoute $route, $parameters)
|
||||
{
|
||||
if (! $route instanceof RouteObjectInterface) {
|
||||
if (!$route instanceof RouteObjectInterface) {
|
||||
// this route has no content, we can't get the alternatives
|
||||
return $route;
|
||||
}
|
||||
$locale = $this->getLocale($parameters);
|
||||
if (! $this->checkLocaleRequirement($route, $locale)) {
|
||||
if (!$this->checkLocaleRequirement($route, $locale)) {
|
||||
$content = $route->getContent();
|
||||
if ($content instanceof RouteReferrersReadInterface) {
|
||||
$routes = $content->getRoutes();
|
||||
|
@ -167,10 +168,10 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
) {
|
||||
$content = $this->contentRepository->findById($parameters['content_id']);
|
||||
if (empty($content)) {
|
||||
throw new RouteNotFoundException('The content repository found nothing at id ' . $parameters['content_id']);
|
||||
throw new RouteNotFoundException('The content repository found nothing at id '.$parameters['content_id']);
|
||||
}
|
||||
if (!$content instanceof RouteReferrersReadInterface) {
|
||||
throw new RouteNotFoundException('Content repository did not return a RouteReferrersReadInterface instance for id ' . $parameters['content_id']);
|
||||
throw new RouteNotFoundException('Content repository did not return a RouteReferrersReadInterface instance for id '.$parameters['content_id']);
|
||||
}
|
||||
} else {
|
||||
$hint = is_object($name) ? get_class($name) : gettype($name);
|
||||
|
@ -182,7 +183,7 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
$hint = ($this->contentRepository && $this->contentRepository->getContentId($content))
|
||||
? $this->contentRepository->getContentId($content)
|
||||
: get_class($content);
|
||||
throw new RouteNotFoundException('Content document has no route: ' . $hint);
|
||||
throw new RouteNotFoundException('Content document has no route: '.$hint);
|
||||
}
|
||||
|
||||
unset($parameters['content_id']);
|
||||
|
@ -209,7 +210,7 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
protected function getRouteByLocale($routes, $locale)
|
||||
{
|
||||
foreach ($routes as $route) {
|
||||
if (! $route instanceof SymfonyRoute) {
|
||||
if (!$route instanceof SymfonyRoute) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -238,7 +239,7 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
}
|
||||
|
||||
/**
|
||||
* Determine the locale to be used with this request
|
||||
* Determine the locale to be used with this request.
|
||||
*
|
||||
* @param array $parameters the parameters determined by the route
|
||||
*
|
||||
|
@ -271,24 +272,24 @@ class ContentAwareGenerator extends ProviderBasedGenerator
|
|||
}
|
||||
|
||||
/**
|
||||
* We additionally support empty name and data in parameters and RouteAware content
|
||||
* We additionally support empty name and data in parameters and RouteAware content.
|
||||
*/
|
||||
public function supports($name)
|
||||
{
|
||||
return ! $name || parent::supports($name) || $name instanceof RouteReferrersReadInterface;
|
||||
return !$name || parent::supports($name) || $name instanceof RouteReferrersReadInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteDebugMessage($name, array $parameters = array())
|
||||
{
|
||||
if (empty($name) && isset($parameters['content_id'])) {
|
||||
return 'Content id ' . $parameters['content_id'];
|
||||
return 'Content id '.$parameters['content_id'];
|
||||
}
|
||||
|
||||
if ($name instanceof RouteReferrersReadInterface) {
|
||||
return 'Route aware content ' . parent::getRouteDebugMessage($name, $parameters);
|
||||
return 'Route aware content '.parent::getRouteDebugMessage($name, $parameters);
|
||||
}
|
||||
|
||||
return parent::getRouteDebugMessage($name, $parameters);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
|
50
vendor/symfony-cmf/routing/DynamicRouter.php
vendored
50
vendor/symfony-cmf/routing/DynamicRouter.php
vendored
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Cmf\Component\Routing;
|
|||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
@ -26,6 +27,7 @@ use Symfony\Cmf\Component\Routing\Enhancer\RouteEnhancerInterface;
|
|||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Cmf\Component\Routing\Event\Events;
|
||||
use Symfony\Cmf\Component\Routing\Event\RouterMatchEvent;
|
||||
use Symfony\Cmf\Component\Routing\Event\RouterGenerateEvent;
|
||||
|
||||
/**
|
||||
* A flexible router accepting matcher and generator through injection and
|
||||
|
@ -57,14 +59,15 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained
|
|||
protected $enhancers = array();
|
||||
|
||||
/**
|
||||
* Cached sorted list of enhancers
|
||||
* Cached sorted list of enhancers.
|
||||
*
|
||||
* @var RouteEnhancerInterface[]
|
||||
*/
|
||||
protected $sortedEnhancers = array();
|
||||
|
||||
/**
|
||||
* The regexp pattern that needs to be matched before a dynamic lookup is made
|
||||
* The regexp pattern that needs to be matched before a dynamic lookup is
|
||||
* made.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
|
@ -96,7 +99,7 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained
|
|||
RouteProviderInterface $provider = null
|
||||
) {
|
||||
$this->context = $context;
|
||||
if (! $matcher instanceof RequestMatcherInterface && ! $matcher instanceof UrlMatcherInterface) {
|
||||
if (!$matcher instanceof RequestMatcherInterface && !$matcher instanceof UrlMatcherInterface) {
|
||||
throw new \InvalidArgumentException('Matcher must implement either Symfony\Component\Routing\Matcher\RequestMatcherInterface or Symfony\Component\Routing\Matcher\UrlMatcherInterface');
|
||||
}
|
||||
$this->matcher = $matcher;
|
||||
|
@ -109,7 +112,7 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteCollection()
|
||||
{
|
||||
|
@ -154,9 +157,9 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained
|
|||
* If the generator is not able to generate the url, it must throw the
|
||||
* RouteNotFoundException as documented below.
|
||||
*
|
||||
* @param string $name The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param Boolean $absolute Whether to generate an absolute URL
|
||||
* @param string|Route $name The name of the route or the Route instance
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param bool|string $referenceType The type of reference to be generated (one of the constants in UrlGeneratorInterface)
|
||||
*
|
||||
* @return string The generated URL
|
||||
*
|
||||
|
@ -164,15 +167,23 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained
|
|||
*
|
||||
* @api
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $absolute = false)
|
||||
public function generate($name, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
|
||||
{
|
||||
return $this->getGenerator()->generate($name, $parameters, $absolute);
|
||||
if ($this->eventDispatcher) {
|
||||
$event = new RouterGenerateEvent($name, $parameters, $referenceType);
|
||||
$this->eventDispatcher->dispatch(Events::PRE_DYNAMIC_GENERATE, $event);
|
||||
$name = $event->getRoute();
|
||||
$parameters = $event->getParameters();
|
||||
$referenceType = $event->getReferenceType();
|
||||
}
|
||||
|
||||
return $this->getGenerator()->generate($name, $parameters, $referenceType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegate to our generator
|
||||
* Delegate to our generator.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports($name)
|
||||
{
|
||||
|
@ -199,22 +210,25 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained
|
|||
* request method is not allowed
|
||||
*
|
||||
* @deprecated Use matchRequest exclusively to avoid problems. This method will be removed in version 2.0
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function match($pathinfo)
|
||||
{
|
||||
@trigger_error(__METHOD__.'() is deprecated since version 1.3 and will be removed in 2.0. Use matchRequest() instead.', E_USER_DEPRECATED);
|
||||
|
||||
$request = Request::create($pathinfo);
|
||||
if ($this->eventDispatcher) {
|
||||
$event = new RouterMatchEvent();
|
||||
$this->eventDispatcher->dispatch(Events::PRE_DYNAMIC_MATCH, $event);
|
||||
}
|
||||
|
||||
if (! empty($this->uriFilterRegexp) && ! preg_match($this->uriFilterRegexp, $pathinfo)) {
|
||||
if (!empty($this->uriFilterRegexp) && !preg_match($this->uriFilterRegexp, $pathinfo)) {
|
||||
throw new ResourceNotFoundException("$pathinfo does not match the '{$this->uriFilterRegexp}' pattern");
|
||||
}
|
||||
|
||||
$matcher = $this->getMatcher();
|
||||
if (! $matcher instanceof UrlMatcherInterface) {
|
||||
if (!$matcher instanceof UrlMatcherInterface) {
|
||||
throw new \InvalidArgumentException('Wrong matcher type, you need to call matchRequest');
|
||||
}
|
||||
|
||||
|
@ -245,8 +259,8 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained
|
|||
$this->eventDispatcher->dispatch(Events::PRE_DYNAMIC_MATCH_REQUEST, $event);
|
||||
}
|
||||
|
||||
if (! empty($this->uriFilterRegexp)
|
||||
&& ! preg_match($this->uriFilterRegexp, $request->getPathInfo())
|
||||
if (!empty($this->uriFilterRegexp)
|
||||
&& !preg_match($this->uriFilterRegexp, $request->getPathInfo())
|
||||
) {
|
||||
throw new ResourceNotFoundException("{$request->getPathInfo()} does not match the '{$this->uriFilterRegexp}' pattern");
|
||||
}
|
||||
|
@ -262,7 +276,7 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained
|
|||
}
|
||||
|
||||
/**
|
||||
* Apply the route enhancers to the defaults, according to priorities
|
||||
* Apply the route enhancers to the defaults, according to priorities.
|
||||
*
|
||||
* @param array $defaults
|
||||
* @param Request $request
|
||||
|
@ -358,7 +372,7 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Forwards to the generator.
|
||||
*/
|
||||
|
|
70
vendor/symfony-cmf/routing/Enhancer/ContentRepositoryEnhancer.php
vendored
Normal file
70
vendor/symfony-cmf/routing/Enhancer/ContentRepositoryEnhancer.php
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?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\Enhancer;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\ContentRepositoryInterface;
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* This enhancer uses a ContentRepositoryInterface to load a content if $target
|
||||
* is empty.
|
||||
*
|
||||
* $source specifies the field that contains the ID to load, $target specifies
|
||||
* the field where to put the content returned by the repository.
|
||||
*
|
||||
* @author Samusev Andrey
|
||||
*/
|
||||
class ContentRepositoryEnhancer implements RouteEnhancerInterface
|
||||
{
|
||||
/**
|
||||
* @var ContentRepositoryInterface
|
||||
*/
|
||||
private $contentRepository;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $target;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @param ContentRepositoryInterface $contentRepository repository to search for the content
|
||||
* @param string $target the field name to set content
|
||||
* @param string $source the field name of the request parameter that contains the id
|
||||
*/
|
||||
public function __construct(
|
||||
ContentRepositoryInterface $contentRepository,
|
||||
$target = RouteObjectInterface::CONTENT_OBJECT,
|
||||
$source = RouteObjectInterface::CONTENT_ID
|
||||
) {
|
||||
$this->contentRepository = $contentRepository;
|
||||
$this->target = $target;
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request)
|
||||
{
|
||||
if (!isset($defaults[$this->target]) && isset($defaults[$this->source])) {
|
||||
$defaults[$this->target] = $this->contentRepository->findById($defaults[$this->source]);
|
||||
}
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -55,7 +55,7 @@ class FieldByClassEnhancer implements RouteEnhancerInterface
|
|||
* If the source field is instance of one of the entries in the map,
|
||||
* target is set to the value of that map entry.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ class FieldByClassEnhancer implements RouteEnhancerInterface
|
|||
return $defaults;
|
||||
}
|
||||
|
||||
if (! isset($defaults[$this->source])) {
|
||||
if (!isset($defaults[$this->source])) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -47,19 +47,19 @@ class FieldMapEnhancer implements RouteEnhancerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* If the target field is not set but the source field is, map the field
|
||||
* If the target field is not set but the source field is, map the field.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request)
|
||||
{
|
||||
if (isset($defaults[$this->target])) {
|
||||
return $defaults;
|
||||
}
|
||||
if (! isset($defaults[$this->source])) {
|
||||
if (!isset($defaults[$this->source])) {
|
||||
return $defaults;
|
||||
}
|
||||
if (! isset($this->hashmap[$defaults[$this->source]])) {
|
||||
if (!isset($this->hashmap[$defaults[$this->source]])) {
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -56,7 +56,7 @@ class FieldPresenceEnhancer implements RouteEnhancerInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request)
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -12,7 +12,6 @@
|
|||
namespace Symfony\Cmf\Component\Routing\Enhancer;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
|
||||
/**
|
||||
|
@ -49,7 +48,7 @@ class RouteContentEnhancer implements RouteEnhancerInterface
|
|||
* If the route has a non-null content and if that content class is in the
|
||||
* injected map, returns that controller.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function enhance(array $defaults, Request $request)
|
||||
{
|
||||
|
@ -58,8 +57,8 @@ class RouteContentEnhancer implements RouteEnhancerInterface
|
|||
return $defaults;
|
||||
}
|
||||
|
||||
if (! isset($defaults[$this->routefield])
|
||||
|| ! $defaults[$this->routefield] instanceof RouteObjectInterface
|
||||
if (!isset($defaults[$this->routefield])
|
||||
|| !$defaults[$this->routefield] instanceof RouteObjectInterface
|
||||
) {
|
||||
// we can't determine the content
|
||||
return $defaults;
|
||||
|
@ -68,7 +67,7 @@ class RouteContentEnhancer implements RouteEnhancerInterface
|
|||
$route = $defaults[$this->routefield];
|
||||
|
||||
$content = $route->getContent();
|
||||
if (! $content) {
|
||||
if (!$content) {
|
||||
// we have no content
|
||||
return $defaults;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -14,7 +14,7 @@ namespace Symfony\Cmf\Component\Routing\Enhancer;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* A route enhancer can change the values in the route data arrays
|
||||
* A route enhancer can change the values in the route data arrays.
|
||||
*
|
||||
* This is useful to provide information to the rest of the routing system
|
||||
* that can be inferred from other parameters rather than hardcode that
|
||||
|
|
17
vendor/symfony-cmf/routing/Event/Events.php
vendored
17
vendor/symfony-cmf/routing/Event/Events.php
vendored
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -14,16 +14,23 @@ namespace Symfony\Cmf\Component\Routing\Event;
|
|||
final class Events
|
||||
{
|
||||
/**
|
||||
* Fired before a path is matched in \Symfony\Cmf\Component\Routing\DynamicRouter#match
|
||||
* Fired before a path is matched in \Symfony\Cmf\Component\Routing\DynamicRouter#match.
|
||||
*
|
||||
* The event object is RouteMatchEvent.
|
||||
* The event object is RouterMatchEvent.
|
||||
*/
|
||||
const PRE_DYNAMIC_MATCH = 'cmf_routing.pre_dynamic_match';
|
||||
|
||||
/**
|
||||
* Fired before a Request is matched in \Symfony\Cmf\Component\Routing\DynamicRouter#match
|
||||
* Fired before a Request is matched in \Symfony\Cmf\Component\Routing\DynamicRouter#match.
|
||||
*
|
||||
* The event object is RouteMatchEvent.
|
||||
* The event object is RouterMatchEvent.
|
||||
*/
|
||||
const PRE_DYNAMIC_MATCH_REQUEST = 'cmf_routing.pre_dynamic_match_request';
|
||||
|
||||
/**
|
||||
* Fired before a route is generated in \Symfony\Cmf\Component\Routing\DynamicRouter#generate.
|
||||
*
|
||||
* The event object is RouterGenerateEvent.
|
||||
*/
|
||||
const PRE_DYNAMIC_GENERATE = 'cmf_routing.pre_dynamic_generate';
|
||||
}
|
||||
|
|
142
vendor/symfony-cmf/routing/Event/RouterGenerateEvent.php
vendored
Normal file
142
vendor/symfony-cmf/routing/Event/RouterGenerateEvent.php
vendored
Normal file
|
@ -0,0 +1,142 @@
|
|||
<?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\Event;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
/**
|
||||
* Event fired before the dynamic router generates a url for a route.
|
||||
*
|
||||
* The name, parameters and absolute properties have the semantics of
|
||||
* UrlGeneratorInterface::generate()
|
||||
*
|
||||
* @author Ben Glassman
|
||||
*
|
||||
* @see \Symfony\Component\Routing\Generator\UrlGeneratorInterface::generate()
|
||||
*/
|
||||
class RouterGenerateEvent extends Event
|
||||
{
|
||||
/**
|
||||
* The name of the route or the Route instance to generate.
|
||||
*
|
||||
* @var string|Route
|
||||
*/
|
||||
private $route;
|
||||
|
||||
/**
|
||||
* The parameters to use when generating the url.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $parameters;
|
||||
|
||||
/**
|
||||
* The type of reference to be generated (one of the constants in UrlGeneratorInterface).
|
||||
*
|
||||
* @var bool|string
|
||||
*/
|
||||
private $referenceType;
|
||||
|
||||
/**
|
||||
* @param string|Route $route The route name or object
|
||||
* @param array $parameters The parameters to use
|
||||
* @param bool|string $referenceType The type of reference to be generated
|
||||
*/
|
||||
public function __construct($route, $parameters, $referenceType)
|
||||
{
|
||||
$this->route = $route;
|
||||
$this->parameters = $parameters;
|
||||
$this->referenceType = $referenceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get route name or object.
|
||||
*
|
||||
* @return string|Route
|
||||
*/
|
||||
public function getRoute()
|
||||
{
|
||||
return $this->route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set route name or object.
|
||||
*
|
||||
* @param string|Route $route
|
||||
*/
|
||||
public function setRoute($route)
|
||||
{
|
||||
$this->route = $route;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get route parameters.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the route parameters.
|
||||
*
|
||||
* @param array $parameters
|
||||
*/
|
||||
public function setParameters(array $parameters)
|
||||
{
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a route parameter.
|
||||
*
|
||||
* @param string $key
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function setParameter($key, $value)
|
||||
{
|
||||
$this->parameters[$key] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a route parameter by key.
|
||||
*
|
||||
* @param string $key
|
||||
*/
|
||||
public function removeParameter($key)
|
||||
{
|
||||
unset($this->parameters[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of reference to be generated (one of the constants in UrlGeneratorInterface).
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
public function getReferenceType()
|
||||
{
|
||||
return $this->referenceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of reference to be generated (one of the constants in UrlGeneratorInterface).
|
||||
*
|
||||
* @param bool|string $referenceType
|
||||
*/
|
||||
public function setReferenceType($referenceType)
|
||||
{
|
||||
$this->referenceType = $referenceType;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
|
2
vendor/symfony-cmf/routing/LICENSE
vendored
2
vendor/symfony-cmf/routing/LICENSE
vendored
|
@ -2,7 +2,7 @@ Routing
|
|||
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2011-2014 Symfony2 CMF
|
||||
Copyright (c) 2011-2015 Symfony CMF
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -69,7 +69,7 @@ class LazyRouteCollection extends RouteCollection
|
|||
try {
|
||||
return $this->provider->getRouteByName($name);
|
||||
} catch (RouteNotFoundException $e) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -24,15 +24,15 @@ use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
|||
interface FinalMatcherInterface
|
||||
{
|
||||
/**
|
||||
* Matches a request against a route collection and returns exactly one result.
|
||||
*
|
||||
* @param RouteCollection $collection The collection against which to match.
|
||||
* @param Request $request The request to match.
|
||||
*
|
||||
* @return array An array of parameters
|
||||
*
|
||||
* @throws ResourceNotFoundException if none of the routes in $collection
|
||||
* matches $request
|
||||
*/
|
||||
* Matches a request against a route collection and returns exactly one result.
|
||||
*
|
||||
* @param RouteCollection $collection The collection against which to match.
|
||||
* @param Request $request The request to match.
|
||||
*
|
||||
* @return array An array of parameters
|
||||
*
|
||||
* @throws ResourceNotFoundException if none of the routes in $collection
|
||||
* matches $request
|
||||
*/
|
||||
public function finalMatch(RouteCollection $collection, Request $request);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -61,7 +61,7 @@ class NestedMatcher implements RequestMatcherInterface
|
|||
protected $sortedFilters = array();
|
||||
|
||||
/**
|
||||
* Constructs a new NestedMatcher
|
||||
* Constructs a new NestedMatcher.
|
||||
*
|
||||
* @param RouteProviderInterface $provider The route provider this matcher
|
||||
* should use
|
||||
|
@ -162,7 +162,7 @@ class NestedMatcher implements RequestMatcherInterface
|
|||
public function getRouteFilters()
|
||||
{
|
||||
if (empty($this->sortedFilters)) {
|
||||
$this->sortedFilters = $this->sortFilters();
|
||||
$this->sortedFilters = $this->sortFilters();
|
||||
}
|
||||
|
||||
return $this->sortedFilters;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -13,7 +13,6 @@ namespace Symfony\Cmf\Component\Routing\NestedMatcher;
|
|||
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -16,7 +16,6 @@ use Symfony\Component\Routing\RouteCollection;
|
|||
use Symfony\Component\Routing\Matcher\UrlMatcher as SymfonyUrlMatcher;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\RequestContext;
|
||||
|
||||
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -85,7 +85,7 @@ class PagedRouteCollection implements \Iterator, \Countable
|
|||
if (false === $result) {
|
||||
$this->loadNextElements($this->current + 1);
|
||||
}
|
||||
$this->current++;
|
||||
++$this->current;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,7 +110,7 @@ class PagedRouteCollection implements \Iterator, \Countable
|
|||
public function rewind()
|
||||
{
|
||||
$this->current = 0;
|
||||
$this->currentRoutes = NULL;
|
||||
$this->currentRoutes = null;
|
||||
$this->loadNextElements($this->current);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
|
@ -8,6 +17,14 @@
|
|||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
@ -23,13 +40,13 @@ interface PagedRouteProviderInterface extends RouteProviderInterface
|
|||
* all routes at once.
|
||||
*
|
||||
* @param int $offset
|
||||
* The sequence will start with that offset in the list of all routes.
|
||||
* The sequence will start with that offset in the list of all routes.
|
||||
* @param int $length [optional]
|
||||
* The sequence will have that many routes in it. If no length is
|
||||
* specified all routes are returned.
|
||||
* The sequence will have that many routes in it. If no length is
|
||||
* specified all routes are returned.
|
||||
*
|
||||
* @return \Symfony\Component\Routing\Route[]
|
||||
* Routes keyed by the route name.
|
||||
* Routes keyed by the route name.
|
||||
*/
|
||||
public function getRoutesPaged($offset, $length = null);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -15,11 +15,10 @@ 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
|
||||
* A Generator that uses a RouteProvider rather than a RouteCollection.
|
||||
*
|
||||
* @author Larry Garfield
|
||||
*/
|
||||
|
@ -44,13 +43,13 @@ class ProviderBasedGenerator extends UrlGenerator implements VersatileGeneratorI
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $absolute = false)
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
|
||||
{
|
||||
if ($name instanceof SymfonyRoute) {
|
||||
$route = $name;
|
||||
} elseif (null === $route = $this->provider->getRouteByName($name, $parameters)) {
|
||||
} elseif (null === $route = $this->provider->getRouteByName($name)) {
|
||||
throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
|
@ -60,13 +59,13 @@ class ProviderBasedGenerator extends UrlGenerator implements VersatileGeneratorI
|
|||
|
||||
$debug_message = $this->getRouteDebugMessage($name);
|
||||
|
||||
return $this->doGenerate($compiledRoute->getVariables(), $route->getDefaults(), $route->getRequirements(), $compiledRoute->getTokens(), $parameters, $debug_message, $absolute, $hostTokens);
|
||||
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
|
||||
* Support a route object and any string as route name.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function supports($name)
|
||||
{
|
||||
|
@ -74,7 +73,7 @@ class ProviderBasedGenerator extends UrlGenerator implements VersatileGeneratorI
|
|||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getRouteDebugMessage($name, array $parameters = array())
|
||||
{
|
||||
|
@ -87,14 +86,13 @@ class ProviderBasedGenerator extends UrlGenerator implements VersatileGeneratorI
|
|||
}
|
||||
|
||||
if ($name instanceof RouteObjectInterface) {
|
||||
return 'Route with key ' . $name->getRouteKey();
|
||||
return 'Route with key '.$name->getRouteKey();
|
||||
}
|
||||
|
||||
if ($name instanceof SymfonyRoute) {
|
||||
return 'Route with pattern ' . $name->getPattern();
|
||||
return 'Route with path '.$name->getPath();
|
||||
}
|
||||
|
||||
return get_class($name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -67,14 +67,14 @@ interface RedirectRouteInterface extends RouteObjectInterface
|
|||
public function getRouteName();
|
||||
|
||||
/**
|
||||
* Whether this should be a permanent or temporary redirect
|
||||
* Whether this should be a permanent or temporary redirect.
|
||||
*
|
||||
* @return boolean
|
||||
* @return bool
|
||||
*/
|
||||
public function isPermanent();
|
||||
|
||||
/**
|
||||
* Get the parameters for the target route router::generate()
|
||||
* Get the parameters for the target route router::generate().
|
||||
*
|
||||
* Note that for the DynamicRouter, you return the target route
|
||||
* document as field 'route' of the hashmap.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -36,13 +36,13 @@ interface RouteObjectInterface
|
|||
const ROUTE_OBJECT = '_route_object';
|
||||
|
||||
/**
|
||||
* Field name for an explicit controller name to be used with this route
|
||||
* Field name for an explicit controller name to be used with this route.
|
||||
*/
|
||||
const CONTROLLER_NAME = '_controller';
|
||||
|
||||
/**
|
||||
* Field name for an explicit template to be used with this route.
|
||||
* i.e. CmfContentBundle:StaticContent:index.html.twig
|
||||
* i.e. CmfContentBundle:StaticContent:index.html.twig.
|
||||
*/
|
||||
const TEMPLATE_NAME = '_template';
|
||||
|
||||
|
@ -51,6 +51,11 @@ interface RouteObjectInterface
|
|||
*/
|
||||
const CONTENT_OBJECT = '_content';
|
||||
|
||||
/**
|
||||
* Field name for the content id of the current route, if any.
|
||||
*/
|
||||
const CONTENT_ID = '_content_id';
|
||||
|
||||
/**
|
||||
* Get the content document this route entry stands for. If non-null,
|
||||
* the ControllerClassMapper uses it to identify a controller and
|
||||
|
@ -64,14 +69,17 @@ interface RouteObjectInterface
|
|||
public function getContent();
|
||||
|
||||
/**
|
||||
* Get the route key.
|
||||
* Get the route name.
|
||||
*
|
||||
* This key will be used as route name instead of the symfony core compatible
|
||||
* route name and can contain any characters.
|
||||
* Normal symfony routes do not know their name, the name is only known
|
||||
* from the route collection. In the CMF, it is possible to use route
|
||||
* documents outside of collections, and thus useful to have routes provide
|
||||
* their name.
|
||||
*
|
||||
* Return null if you want to use the default key.
|
||||
* There are no limitations to allowed characters in the name.
|
||||
*
|
||||
* @return string the route name
|
||||
* @return string|null the route name or null to use the default name
|
||||
* (e.g. from route collection if known)
|
||||
*/
|
||||
public function getRouteKey();
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -82,7 +82,7 @@ interface RouteProviderInterface
|
|||
* the provider will determine what routes to return.
|
||||
*
|
||||
* @return Route[] Iterable list with the keys being the names from the
|
||||
* $names array.
|
||||
* $names array.
|
||||
*/
|
||||
public function getRoutesByNames($names);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* This file is part of the Symfony CMF package.
|
||||
*
|
||||
* (c) 2011-2014 Symfony CMF
|
||||
* (c) 2011-2015 Symfony CMF
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
|
@ -34,7 +34,7 @@ interface VersatileGeneratorInterface extends UrlGeneratorInterface
|
|||
|
||||
/**
|
||||
* Convert a route identifier (name, content object etc) into a string
|
||||
* usable for logging and other debug/error messages
|
||||
* usable for logging and other debug/error messages.
|
||||
*
|
||||
* @param mixed $name
|
||||
* @param array $parameters which should contain a content field containing
|
||||
|
|
21
vendor/symfony-cmf/routing/composer.json
vendored
21
vendor/symfony-cmf/routing/composer.json
vendored
|
@ -11,20 +11,21 @@
|
|||
"homepage": "https://github.com/symfony-cmf/Routing/contributors"
|
||||
}
|
||||
],
|
||||
"minimum-stability": "dev",
|
||||
"require": {
|
||||
"php": ">=5.3.3",
|
||||
"symfony/routing": "~2.2",
|
||||
"symfony/http-kernel": "~2.2",
|
||||
"psr/log": "~1.0"
|
||||
"php": "^5.3.9|^7.0",
|
||||
"symfony/routing": "^2.2|3.*",
|
||||
"symfony/http-kernel": "^2.2|3.*",
|
||||
"psr/log": "1.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/dependency-injection": "~2.0@stable",
|
||||
"symfony/config": "~2.2",
|
||||
"symfony/event-dispatcher": "~2.1"
|
||||
"symfony-cmf/testing": "^1.3",
|
||||
"symfony/dependency-injection": "^2.0.5|3.*",
|
||||
"symfony/config": "^2.2|3.*",
|
||||
"symfony/event-dispatcher": "^2.1|3.*",
|
||||
"friendsofsymfony/jsrouting-bundle": "^1.1"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/event-dispatcher": "DynamicRouter can optionally trigger an event at the start of matching. Minimal version ~2.1"
|
||||
"symfony/event-dispatcher": "DynamicRouter can optionally trigger an event at the start of matching. Minimal version (~2.1)"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -33,7 +34,7 @@
|
|||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.3-dev"
|
||||
"dev-master": "1.4-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
vendor/symfony-cmf/routing/phpunit.xml.dist
vendored
2
vendor/symfony-cmf/routing/phpunit.xml.dist
vendored
|
@ -3,7 +3,7 @@
|
|||
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
|
||||
<phpunit
|
||||
colors="true"
|
||||
bootstrap="Tests/bootstrap.php"
|
||||
bootstrap="vendor/symfony-cmf/testing/bootstrap/bootstrap.php"
|
||||
>
|
||||
|
||||
<testsuites>
|
||||
|
|
Reference in a new issue