integrate symfony-cmf/Routing component using chainRouter
This commit is contained in:
@@ -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" : {
|
||||
|
||||
51
composer.lock
generated
51
composer.lock
generated
@@ -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",
|
||||
|
||||
95
core/lib/Thelia/Routing/NullUrlGenerator.php
Normal file
95
core/lib/Thelia/Routing/NullUrlGenerator.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,12 @@
|
||||
<loop name="foo" class="Foo\Bar"/>
|
||||
<loop name="fooz" class="Foo\Barz"/>
|
||||
</loops>
|
||||
<parameters>
|
||||
<parameter key="router.request_context.class">Symfony\Component\Routing\RequestContext</parameter>
|
||||
<parameter key="router.null_generator.class">Thelia\Routing\NullUrlGenerator</parameter>
|
||||
<parameter key="router.dynamicRouter.class">Symfony\Cmf\Component\Routing\DynamicRouter</parameter>
|
||||
<parameter key="router.chainRouter.class">Symfony\Cmf\Component\Routing\ChainRouter</parameter>
|
||||
</parameters>
|
||||
<services>
|
||||
<service id="event_dispatcher" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
|
||||
<argument type="service" id="service_container" />
|
||||
@@ -28,26 +34,29 @@
|
||||
<argument type="service" id="controller.default"/>
|
||||
</service>
|
||||
|
||||
<!-- <service id="matcher.action" class="Thelia\Routing\Matcher\ActionMatcher">
|
||||
<call method="setDispatcher">
|
||||
<argument type="service" id="event_dispatcher"/>
|
||||
</call>
|
||||
</service>-->
|
||||
<service id="request.context" class="%router.request_context.class%" />
|
||||
|
||||
<service id="matcher" class="Thelia\Routing\TheliaMatcherCollection">
|
||||
<service id="router.null_generator" class="%router.null_generator.class%"/>
|
||||
|
||||
<service id="router.default_route" class="%router.dynamicRouter.class%">
|
||||
<argument type="service" id="request.context"/>
|
||||
<argument type="service" id="matcher.default"/>
|
||||
<argument type="service" id="router.null_generator"/>
|
||||
</service>
|
||||
|
||||
<service id="router.chainRequest" class="%router.chainRouter.class%">
|
||||
<call method="setContext">
|
||||
<argument type="service" id="request.context"/>
|
||||
</call>
|
||||
<call method="add">
|
||||
<argument type="service" id="matcher.default"/>
|
||||
<argument type="service" id="router.default_route"/>
|
||||
<argument>-255</argument>
|
||||
</call>
|
||||
<!-- <call method="add">
|
||||
<argument type="service" id="matcher.action"/>
|
||||
<argument>-200</argument>
|
||||
</call>-->
|
||||
</service>
|
||||
|
||||
<service id="listener.router" class="Symfony\Component\HttpKernel\EventListener\RouterListener">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
<argument type="service" id="matcher"/>
|
||||
<argument type="service" id="router.chainRequest"/>
|
||||
</service>
|
||||
|
||||
<service id="thelia.request_listener" class="Thelia\Core\EventListener\RequestListener">
|
||||
|
||||
Reference in New Issue
Block a user