From bb86533f25ab9b2ab35e2f4e35f85adf28bb84cd Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 5 Feb 2013 18:19:47 +0100 Subject: [PATCH] start to implement action matcher --- core/lib/Thelia/Core/Bundle/TheliaBundle.php | 7 ++- .../Thelia/Routing/Matcher/ActionMatcher.php | 47 +++++++++++++++++++ .../Thelia/Routing/Matcher/DefaultMatcher.php | 22 ++++++++- .../{Matcher => }/TheliaMatcherCollection.php | 24 +++++++++- 4 files changed, 95 insertions(+), 5 deletions(-) create mode 100644 core/lib/Thelia/Routing/Matcher/ActionMatcher.php rename core/lib/Thelia/Routing/{Matcher => }/TheliaMatcherCollection.php (69%) diff --git a/core/lib/Thelia/Core/Bundle/TheliaBundle.php b/core/lib/Thelia/Core/Bundle/TheliaBundle.php index 205847855..3d1e46d64 100644 --- a/core/lib/Thelia/Core/Bundle/TheliaBundle.php +++ b/core/lib/Thelia/Core/Bundle/TheliaBundle.php @@ -58,8 +58,11 @@ class TheliaBundle extends Bundle $container->register('matcher.default','Thelia\Routing\Matcher\DefaultMatcher') ->addArgument(new Reference('controller.default')); - $container->register('matcher','Thelia\Routing\Matcher\TheliaMatcherCollection') + $container->register('matcher.action', 'Thelia\Routing\Matcher\ActionMatcher'); + + $container->register('matcher','Thelia\Routing\TheliaMatcherCollection') ->addMethodCall('add', array(new Reference('matcher.default'), -255)) + ->addMethodCall('add', array(new Reference('matcher.action'), -200)) //->addMethodCall('add','a matcher class (instance or class name) ; @@ -73,7 +76,7 @@ class TheliaBundle extends Bundle * RouterListener implements EventSubscriberInterface and listen for kernel.request event */ $container->register('listener.router', 'Symfony\Component\HttpKernel\EventListener\RouterListener') - ->setArguments(array(new Reference('matcher'))) + ->addArgument(new Reference('matcher')) ; /** diff --git a/core/lib/Thelia/Routing/Matcher/ActionMatcher.php b/core/lib/Thelia/Routing/Matcher/ActionMatcher.php new file mode 100644 index 000000000..4b4431652 --- /dev/null +++ b/core/lib/Thelia/Routing/Matcher/ActionMatcher.php @@ -0,0 +1,47 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Routing\Matcher; + +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Routing\Matcher\RequestMatcherInterface; +use Symfony\Component\Routing\Exception\ResourceNotFoundException; + +class ActionMatcher implements RequestMatcherInterface +{ + public function matchRequest(Request $request) + { + if (false !== $action = $request->get("action")) { + + //search corresponding action + + } + + throw new ResourceNotFoundException("No action parameter found"); + } + + protected function findActionParam(Request $request) + { + + } +} diff --git a/core/lib/Thelia/Routing/Matcher/DefaultMatcher.php b/core/lib/Thelia/Routing/Matcher/DefaultMatcher.php index 2e8a158ca..b0ce6b841 100644 --- a/core/lib/Thelia/Routing/Matcher/DefaultMatcher.php +++ b/core/lib/Thelia/Routing/Matcher/DefaultMatcher.php @@ -1,5 +1,25 @@ . */ +/* */ +/*************************************************************************************/ namespace Thelia\Routing\Matcher; use Symfony\Component\HttpFoundation\Request; diff --git a/core/lib/Thelia/Routing/Matcher/TheliaMatcherCollection.php b/core/lib/Thelia/Routing/TheliaMatcherCollection.php similarity index 69% rename from core/lib/Thelia/Routing/Matcher/TheliaMatcherCollection.php rename to core/lib/Thelia/Routing/TheliaMatcherCollection.php index ebaa3c83a..bf1c8e2f2 100644 --- a/core/lib/Thelia/Routing/Matcher/TheliaMatcherCollection.php +++ b/core/lib/Thelia/Routing/TheliaMatcherCollection.php @@ -1,6 +1,26 @@ . */ +/* */ +/*************************************************************************************/ +namespace Thelia\Routing; use Symfony\Component\Routing\Matcher\RequestMatcherInterface; use Symfony\Component\Routing\Exception\ResourceNotFoundException;