diff --git a/composer.json b/composer.json index cbba9748b..30dd5a10d 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "symfony/event-dispatcher" : "2.2.*", "symfony/http-kernel" : "2.2.*", "symfony/routing" : "2.2.*", - "symfony/yaml" : "2.2.*" + "symfony/yaml" : "2.2.*", + "symfony-cmf/routing": "1.0.0" }, "minimum-stability": "stable", "config" : { diff --git a/composer.lock b/composer.lock index faff0a016..a266b1c29 100644 --- a/composer.lock +++ b/composer.lock @@ -1,5 +1,5 @@ { - "hash": "cf4088dc8f62e5c8b39d474fbcc90de3", + "hash": "05d2d7252b42f45fd8415a6c47087d97", "packages": [ { "name": "ezyang/htmlpurifier", @@ -234,6 +234,55 @@ ], "time": "2012-12-21 11:40:51" }, + { + "name": "symfony-cmf/routing", + "version": "1.0.0", + "target-dir": "Symfony/Cmf/Component/Routing", + "source": { + "type": "git", + "url": "https://github.com/symfony-cmf/Routing.git", + "reference": "1.0.0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/1.0.0", + "reference": "1.0.0", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "symfony/http-kernel": ">=2.1,<2.3-dev", + "symfony/routing": ">=2.1,<2.3-dev" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-0": { + "Symfony\\Cmf\\Component\\Routing": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Symfony CMF Community", + "homepage": "https://github.com/symfony-cmf/Routing/contributors" + } + ], + "description": "Extends the Symfony2 routing component for dynamic routes and chaining several routers", + "homepage": "http://cmf.symfony.com", + "keywords": [ + "database", + "routing" + ], + "time": "2013-03-25 15:02:40" + }, { "name": "symfony/class-loader", "version": "v2.2.1", diff --git a/core/lib/Thelia/Routing/NullUrlGenerator.php b/core/lib/Thelia/Routing/NullUrlGenerator.php new file mode 100644 index 000000000..0206a7f2e --- /dev/null +++ b/core/lib/Thelia/Routing/NullUrlGenerator.php @@ -0,0 +1,95 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Routing; + + + +use Symfony\Component\Routing\Exception\InvalidParameterException; +use Symfony\Component\Routing\Exception\MissingMandatoryParametersException; +use Symfony\Component\Routing\Exception\RouteNotFoundException; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Routing\RequestContext; + +class NullUrlGenerator implements UrlGeneratorInterface +{ + + protected $context; + + /** + * Sets the request context. + * + * @param RequestContext $context The context + * + * @api + */ + public function setContext(RequestContext $context) + { + $this->context = $context; + } + + /** + * Gets the request context. + * + * @return RequestContext The context + * + * @api + */ + public function getContext() + { + return $this->context; + } + + /** + * Generates a URL or path for a specific route based on the given parameters. + * + * Parameters that reference placeholders in the route pattern will substitute them in the + * path or host. Extra params are added as query string to the URL. + * + * When the passed reference type cannot be generated for the route because it requires a different + * host or scheme than the current one, the method will return a more comprehensive reference + * that includes the required params. For example, when you call this method with $referenceType = ABSOLUTE_PATH + * but the route requires the https scheme whereas the current scheme is http, it will instead return an + * ABSOLUTE_URL with the https scheme and the current host. This makes sure the generated URL matches + * the route in any case. + * + * If there is no route with the given name, the generator must throw the RouteNotFoundException. + * + * @param string $name The name of the route + * @param mixed $parameters An array of parameters + * @param Boolean|string $referenceType The type of reference to be generated (one of the constants) + * + * @return string The generated URL + * + * @throws RouteNotFoundException If the named route doesn't exist + * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route + * @throws InvalidParameterException When a parameter value for a placeholder is not correct because + * it does not match the requirement + * + * @api + */ + public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) + { + throw new InvalidParameterException("this generator cannot be used"); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/config.xml b/core/lib/Thelia/config.xml index 8d9bbf7de..4e9132f34 100644 --- a/core/lib/Thelia/config.xml +++ b/core/lib/Thelia/config.xml @@ -12,6 +12,12 @@ + + Symfony\Component\Routing\RequestContext + Thelia\Routing\NullUrlGenerator + Symfony\Cmf\Component\Routing\DynamicRouter + Symfony\Cmf\Component\Routing\ChainRouter + @@ -28,26 +34,29 @@ - + - + + + + + + + + + + + + - + -255 - - +