Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

minor changes #127

Closed
wants to merge 2 commits into from

3 participants

@recck

fixed the payload being set too late, and updated the regex filter patterns.

@travisbot

This pull request passes (merged 2fbda3f into a530239).

@trq

These three lines should actually be moved back to where they came from.

@trq

This object should NOT actually be instantiated here. This need to be moved into the dispatch() method.

@trq

The above comment would mean that this test would need to be done via Reflection.

@trq
Owner

A few things here. Firstly, thanks for taking the time, however, if you look at the diffs for 6eef5d4 and 2fbda3f you can see that you are replacing the entire file with new content. I assume your using Windows and that this is related to your line ending settings. I should probably set a git attribute for this in the base of the repo, but for now take a look at https://help.github.com/articles/dealing-with-line-endings#platform-windows and re-commit.

Because these are unrelated changes, they really need to be within separate feature branches and pull request

The other thing is in relation to the setting of the payload within isDispatchable(). I know I said to try this solution as it might (and does indeed) fix the underlying issue. However, we now have an issue where isDispatchable() has more responsibility than it should.

The fact is, it's always had to much responsibility, but I need to now fix it. I have commented on this issue inline.

If you want to fix these issues and send a new pull request go ahead. Otherwise, just let me know and I'll take care of them myself.

@trq
Owner
trq commented

There is no way this request can be merged due to the line ending issue.

I have fixed the payload being set too late myself.

@trq trq closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 30, 2012
  1. @recck

    fixed payload being set too late

    recck authored
  2. @recck

    updated filter regex patterns

    recck authored
This page is out of date. Refresh to see the latest.
Showing with 382 additions and 381 deletions.
  1. +194 −193 lib/Proem/Dispatch/Standard.php
  2. +188 −188 lib/Proem/Routing/Route/Standard.php
View
387 lib/Proem/Dispatch/Standard.php
@@ -1,193 +1,194 @@
-<?php
-
-/**
- * The MIT License
- *
- * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-/**
- * @namespace Proem\Dispatch
- */
-namespace Proem\Dispatch;
-
-use Proem\Dispatch\Template as Template,
- Proem\Service\Manager\Template as Manager,
- Proem\Routing\Route\Payload as Payload;
-
-/**
- * Proem\Dispatch\Standard
- */
-class Standard implements Template
-{
- /**
- * Store the Assets manager
- *
- * @var Proem\Service\Manager\Template
- */
- protected $assets;
-
- /**
- * Store an array of patterns used to searching
- * for classes within a namepspace.
- *
- * @var array $controllerMaps
- */
- protected $controllerMaps = [];
-
- /**
- * Store the absolute namespace to the current class
- *
- * @var string $class
- */
- protected $class;
-
- /**
- * Store the Router Payload.
- *
- * @var Proem\Routing\Route\Payload $payload
- */
- protected $payload;
-
- /**
- * Store the module name
- *
- * @var string $module
- */
- protected $module;
-
- /**
- * Store the controller name
- *
- * @var string $controller
- */
- protected $controller;
-
- /**
- * Store the action name
- *
- * @var string $action
- */
- protected $action;
-
- /**
- * Setup the dispatcher
- *
- * @param Proem\Service\Manager\Template $assets
- */
- public function __construct(Manager $assets)
- {
- $this->assets = $assets;
- $this->controllerMaps = ['Module\:module\Controller\:controller'];
- }
-
- /**
- * Set the payload object
- *
- * @param Proem\Routing\Route\Payload $payload
- * @return Proem\Dispatch\Template
- */
- public function setPayload(Payload $payload)
- {
- $this->payload = $payload;
- return $this;
- }
-
- /**
- * Add a new controller map onto the stack of controller
- * maps.
- *
- * This method allows us to add different directory structures
- * which the dispatcher can use to locate controllers.
- *
- * The default controller map looks like: 'Module\:module\Controller\:controller'
- *
- * You can create your own. The tokens :module and :controller will be replaced
- * with the module and controller that are made available via the payload.
- *
- * @param string $map
- * @return Proem\Dispatch\Template
- */
- public function attachControllerMap($map) {
- $this->controllerMaps[] = $map;
- return $this;
- }
-
- /**
- * Test to see if the current payload is dispatchable.
- *
- * This method iterates through all of the controller maps
- * and checks to see if the class can be instantiated and the
- * action executed.
- *
- * This method will actually store an instantiated controller
- * within the $class property of this Dispatch object.
- *
- * @return bool
- */
- public function isDispatchable()
- {
- $this->module = $this->payload->has('module') ? ucfirst(strtolower($this->payload->get('module'))) : '';
- $this->controller = $this->payload->has('controller') ? ucfirst(strtolower($this->payload->get('controller'))) : '';
- $this->action = $this->payload->has('action') ? $this->payload->get('action') : '';
-
- foreach ($this->controllerMaps as $map) {
- $this->class = str_replace(
- [':module', ':controller'],
- [$this->module, $this->controller],
- $map
- );
-
- if (class_exists($this->class)) {
- $this->class = new $this->class($this->assets);
- if ($this->class instanceof \Proem\Controller\Template) {
- if (is_callable([$this->class, $this->action . 'Action'])) {
- return true;
- }
- }
- }
- }
-
- return false;
- }
-
- /**
- * Dispatch the current controller stored within
- * the $class property.
- *
- * Prior to dispatch this method will send the Payload to the Request
- * object stored within the Service Manager. At this point we also call
- * the Payload's prepare method, which prepares the Payload for the Request.
- *
- * It will then execute the controllers preAction method, the action
- * method provided by the payload, then postAction.
- *
- * @return Proem\Dispatch\Standard
- */
- public function dispatch()
- {
- if ($this->assets->has('request')) {
- $this->assets->get('request')->injectPayload($this->payload->prepare());
- }
- $this->class->dispatch($this->action);
- return $this;
- }
-}
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+/**
+ * @namespace Proem\Dispatch
+ */
+namespace Proem\Dispatch;
+
+use Proem\Dispatch\Template as Template,
+ Proem\Service\Manager\Template as Manager,
+ Proem\Routing\Route\Payload as Payload;
+
+/**
+ * Proem\Dispatch\Standard
+ */
+class Standard implements Template
+{
+ /**
+ * Store the Assets manager
+ *
+ * @var Proem\Service\Manager\Template
+ */
+ protected $assets;
+
+ /**
+ * Store an array of patterns used to searching
+ * for classes within a namepspace.
+ *
+ * @var array $controllerMaps
+ */
+ protected $controllerMaps = [];
+
+ /**
+ * Store the absolute namespace to the current class
+ *
+ * @var string $class
+ */
+ protected $class;
+
+ /**
+ * Store the Router Payload.
+ *
+ * @var Proem\Routing\Route\Payload $payload
+ */
+ protected $payload;
+
+ /**
+ * Store the module name
+ *
+ * @var string $module
+ */
+ protected $module;
+
+ /**
+ * Store the controller name
+ *
+ * @var string $controller
+ */
+ protected $controller;
+
+ /**
+ * Store the action name
+ *
+ * @var string $action
+ */
+ protected $action;
+
+ /**
+ * Setup the dispatcher
+ *
+ * @param Proem\Service\Manager\Template $assets
+ */
+ public function __construct(Manager $assets)
+ {
+ $this->assets = $assets;
+ $this->controllerMaps = ['Module\:module\Controller\:controller'];
+ }
+
+ /**
+ * Set the payload object
+ *
+ * @param Proem\Routing\Route\Payload $payload
+ * @return Proem\Dispatch\Template
+ */
+ public function setPayload(Payload $payload)
+ {
+ $this->payload = $payload;
+ return $this;
+ }
+
+ /**
+ * Add a new controller map onto the stack of controller
+ * maps.
+ *
+ * This method allows us to add different directory structures
+ * which the dispatcher can use to locate controllers.
+ *
+ * The default controller map looks like: 'Module\:module\Controller\:controller'
+ *
+ * You can create your own. The tokens :module and :controller will be replaced
+ * with the module and controller that are made available via the payload.
+ *
+ * @param string $map
+ * @return Proem\Dispatch\Template
+ */
+ public function attachControllerMap($map) {
+ $this->controllerMaps[] = $map;
+ return $this;
+ }
+
+ /**
+ * Test to see if the current payload is dispatchable.
+ *
+ * This method iterates through all of the controller maps
+ * and checks to see if the class can be instantiated and the
+ * action executed.
+ *
+ * This method will actually store an instantiated controller
+ * within the $class property of this Dispatch object.
+ *
+ * @return bool
+ */
+ public function isDispatchable()
+ {
+ $this->module = $this->payload->has('module') ? ucfirst(strtolower($this->payload->get('module'))) : '';
+ $this->controller = $this->payload->has('controller') ? ucfirst(strtolower($this->payload->get('controller'))) : '';
+ $this->action = $this->payload->has('action') ? $this->payload->get('action') : '';
+
+ if ($this->assets->has('request')) {
+ $this->assets->get('request')->injectPayload($this->payload->prepare());
+ }
+
+ foreach ($this->controllerMaps as $map) {
+ $this->class = str_replace(
+ [':module', ':controller'],
+ [$this->module, $this->controller],
+ $map
+ );
+
+ if (class_exists($this->class)) {
+ $this->class = new $this->class($this->assets);
+ if ($this->class instanceof \Proem\Controller\Template) {
+ if (is_callable([$this->class, $this->action . 'Action'])) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Dispatch the current controller stored within
+ * the $class property.
+ *
+ * Prior to dispatch this method will send the Payload to the Request
+ * object stored within the Service Manager. At this point we also call
+ * the Payload's prepare method, which prepares the Payload for the Request.
+ *
+ * It will then execute the controllers preAction method, the action
+ * method provided by the payload, then postAction.
+ *
+ * @return Proem\Dispatch\Standard
+ */
+ public function dispatch()
+ {
+ $this->class->dispatch($this->action);
+ return $this;
+ }
+}
View
376 lib/Proem/Routing/Route/Standard.php
@@ -1,188 +1,188 @@
-<?php
-
-/**
- * The MIT License
- *
- * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-
-/**
- * @namespace Proem\Routing\Route
- */
-namespace Proem\Routing\Route;
-
-use Proem\Routing\Route\Template,
- Proem\Routing\Route\Generic,
- Proem\IO\Request\Template as Request;
-
-/**
- * Proem's standard route.
- *
- * This route should cover most use cases and is currently the only
- * route provided within the framework.
- */
-class Standard extends Generic
-{
- /**
- * Store default tokens.
- *
- * @var array
- */
- protected $default_tokens = [];
-
- /**
- * Store default filters.
- *
- * @var array
- */
- protected $default_filters = [];
-
- /**
- * Instantiate object & setup default filters / tokens.
- *
- * @param array $options Array of Proem\Utils\Option objects
- */
- public function __construct(array $options) {
- parent::__construct($options);
-
- $this->default_filters = [
- ':default' => '[a-zA-Z0-9_\+\-%]+',
- ':gobble' => '[a-zA-Z0-9_\+\-%\/]+',
- ':int' => '[0-9]+',
- ':alpha' => '[a-zA-Z]+',
- ':slug' => '[a-zA-Z0-9_-]+'
- ];
-
- $this->default_tokens = [
- 'module' => $this->default_filters[':default'],
- 'controller' => $this->default_filters[':default'],
- 'action' => $this->default_filters[':default'],
- 'params' => $this->default_filters[':gobble']
- ];
- }
-
- /**
- * Process the supplied url.
- *
- * This route takes a simplified series of patterns such as :controller and
- * replaces them with more complex regular expressions which are then used
- * within a preg_match_callback to match against the given uri.
- *
- * A default rule of /:controller/:action/:params is used if no rule is
- * provided through the $options array.
- *
- * If a 'filter' regex is set within the $options array that regex will be
- * used within the preg_match_callback. Otherwise a default regex of
- * ([a-zA-Z0-9_\+\-%]+) is used.
- *
- * If one of the 'simplified' patterns within the rule is :params, this is
- * treated specially and uses a ([a-zA-Z0-9_\+\-%\/]+) regex which will match
- * the same as the default as well as / .
- *
- * This causes the pattern to match entire sections of uri's. Allowing a
- * simple pattern like the default /:controller/:action/:params to match
- * uri's like /foo/bar/a/b/c/d/e/f/g/h and cause everything after /foo/bar
- * to be added to the Payload object as params (which are in turn transformed
- * into key => value pairs).
- *
- * @param Proem\IO\Request\Template $request
- * @return Proem\Routing\Route\Template
- */
- public function process(Request $request)
- {
- if (!isset($this->options['rule'])) {
- return false;
- }
-
- $rule = $this->options['rule'];
- $target = isset($this->options['targets']) ? $this->options['targets'] : [];
- $custom_filters = isset($this->options['filters']) ? $this->options['filters'] : [];
- $method = isset($this->options['method']) ? $this->options['method'] : false;
-
- $requestMethod = $request->getMethod();
-
- if ($method && (strtoupper($method) !== strtoupper($requestMethod))) {
- return false;
- }
-
- $default_tokens = $this->default_tokens;
- $default_filters = $this->default_filters;
- $uri = $request->getRequestUri();
-
- $keys = [];
- $values = [];
- $params = [];
-
- preg_match_all('@:([\w]+)@', $rule, $keys, PREG_PATTERN_ORDER);
- $keys = $keys[0];
-
- $regex = preg_replace_callback(
- '@:[\w]+@',
- function($matches) use ($custom_filters, $default_tokens, $default_filters)
- {
- $key = str_replace(':', '', $matches[0]);
- if (isset($custom_filters[$key])) {
- if (isset($default_filters[$custom_filters[$key]])) {
- return '(' . $default_filters[$custom_filters[$key]] . ')';
- } else {
- return '(' . $custom_filters[$key] . ')';
- }
- } else if (isset($default_tokens[$key])) {
- return '(' . $default_tokens[$key] . ')';
- } else {
- return '(' . $default_filters[':default'] . ')';
- }
- },
- $rule
- ) . '/?';
-
- if (preg_match('@^' . $regex . '$@', $request->getRequestUri(), $values)) {
- array_shift($values);
-
- foreach ($keys as $index => $value) {
- if (isset($values[$index])) {
- $params[substr($value, 1)] = urldecode($values[$index]);
- }
- }
-
- foreach ($target as $key => $value) {
- $params[$key] = $value;
- }
-
- foreach ($params as $key => $value) {
- // If the string within $value looks like a / seperated string,
- // parse it into an array and send it to setParams() instead
- // of the singular setParam.
- if ($key == 'params') {
- $this->getPayload()->set('params', $this->createAssocArray(explode('/', trim($value, '/'))));
- } else {
- $this->getPayload()->set($key, $value);
- }
- }
-
- $this->setMatch();
- $this->getPayload()->set('request', $request);
- $this->getPayload()->setPopulated();
- }
- return $this;
- }
-}
+<?php
+
+/**
+ * The MIT License
+ *
+ * Copyright (c) 2010 - 2012 Tony R Quilkey <trq@proemframework.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+
+/**
+ * @namespace Proem\Routing\Route
+ */
+namespace Proem\Routing\Route;
+
+use Proem\Routing\Route\Template,
+ Proem\Routing\Route\Generic,
+ Proem\IO\Request\Template as Request;
+
+/**
+ * Proem's standard route.
+ *
+ * This route should cover most use cases and is currently the only
+ * route provided within the framework.
+ */
+class Standard extends Generic
+{
+ /**
+ * Store default tokens.
+ *
+ * @var array
+ */
+ protected $default_tokens = [];
+
+ /**
+ * Store default filters.
+ *
+ * @var array
+ */
+ protected $default_filters = [];
+
+ /**
+ * Instantiate object & setup default filters / tokens.
+ *
+ * @param array $options Array of Proem\Utils\Option objects
+ */
+ public function __construct(array $options) {
+ parent::__construct($options);
+
+ $this->default_filters = [
+ ':default' => '[\w\+\-%]+',
+ ':gobble' => '[\w\+\-%\/]+',
+ ':int' => '[\d]+',
+ ':alpha' => '[a-zA-Z]+',
+ ':slug' => '[\w-]+'
+ ];
+
+ $this->default_tokens = [
+ 'module' => $this->default_filters[':default'],
+ 'controller' => $this->default_filters[':default'],
+ 'action' => $this->default_filters[':default'],
+ 'params' => $this->default_filters[':gobble']
+ ];
+ }
+
+ /**
+ * Process the supplied url.
+ *
+ * This route takes a simplified series of patterns such as :controller and
+ * replaces them with more complex regular expressions which are then used
+ * within a preg_match_callback to match against the given uri.
+ *
+ * A default rule of /:controller/:action/:params is used if no rule is
+ * provided through the $options array.
+ *
+ * If a 'filter' regex is set within the $options array that regex will be
+ * used within the preg_match_callback. Otherwise a default regex of
+ * ([a-zA-Z0-9_\+\-%]+) is used.
+ *
+ * If one of the 'simplified' patterns within the rule is :params, this is
+ * treated specially and uses a ([a-zA-Z0-9_\+\-%\/]+) regex which will match
+ * the same as the default as well as / .
+ *
+ * This causes the pattern to match entire sections of uri's. Allowing a
+ * simple pattern like the default /:controller/:action/:params to match
+ * uri's like /foo/bar/a/b/c/d/e/f/g/h and cause everything after /foo/bar
+ * to be added to the Payload object as params (which are in turn transformed
+ * into key => value pairs).
+ *
+ * @param Proem\IO\Request\Template $request
+ * @return Proem\Routing\Route\Template
+ */
+ public function process(Request $request)
+ {
+ if (!isset($this->options['rule'])) {
+ return false;
+ }
+
+ $rule = $this->options['rule'];
+ $target = isset($this->options['targets']) ? $this->options['targets'] : [];
+ $custom_filters = isset($this->options['filters']) ? $this->options['filters'] : [];
+ $method = isset($this->options['method']) ? $this->options['method'] : false;
+
+ $requestMethod = $request->getMethod();
+
+ if ($method && (strtoupper($method) !== strtoupper($requestMethod))) {
+ return false;
+ }
+
+ $default_tokens = $this->default_tokens;
+ $default_filters = $this->default_filters;
+ $uri = $request->getRequestUri();
+
+ $keys = [];
+ $values = [];
+ $params = [];
+
+ preg_match_all('@:([\w]+)@', $rule, $keys, PREG_PATTERN_ORDER);
+ $keys = $keys[0];
+
+ $regex = preg_replace_callback(
+ '@:[\w]+@',
+ function($matches) use ($custom_filters, $default_tokens, $default_filters)
+ {
+ $key = str_replace(':', '', $matches[0]);
+ if (isset($custom_filters[$key])) {
+ if (isset($default_filters[$custom_filters[$key]])) {
+ return '(' . $default_filters[$custom_filters[$key]] . ')';
+ } else {
+ return '(' . $custom_filters[$key] . ')';
+ }
+ } else if (isset($default_tokens[$key])) {
+ return '(' . $default_tokens[$key] . ')';
+ } else {
+ return '(' . $default_filters[':default'] . ')';
+ }
+ },
+ $rule
+ ) . '/?';
+
+ if (preg_match('@^' . $regex . '$@', $request->getRequestUri(), $values)) {
+ array_shift($values);
+
+ foreach ($keys as $index => $value) {
+ if (isset($values[$index])) {
+ $params[substr($value, 1)] = urldecode($values[$index]);
+ }
+ }
+
+ foreach ($target as $key => $value) {
+ $params[$key] = $value;
+ }
+
+ foreach ($params as $key => $value) {
+ // If the string within $value looks like a / seperated string,
+ // parse it into an array and send it to setParams() instead
+ // of the singular setParam.
+ if ($key == 'params') {
+ $this->getPayload()->set('params', $this->createAssocArray(explode('/', trim($value, '/'))));
+ } else {
+ $this->getPayload()->set($key, $value);
+ }
+ }
+
+ $this->setMatch();
+ $this->getPayload()->set('request', $request);
+ $this->getPayload()->setPopulated();
+ }
+ return $this;
+ }
+}
Something went wrong with that request. Please try again.