Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Mvc / Router / Http / Query.php
blobe7a322a8817691eff02f600db9b0b6008eaf7fa8
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Mvc\Router\Http;
12 use Traversable;
13 use Zend\Mvc\Router\Exception;
14 use Zend\Mvc\Router\Http\RouteMatch;
15 use Zend\Stdlib\ArrayUtils;
16 use Zend\Stdlib\RequestInterface as Request;
18 /**
19 * Query route.
21 * @deprecated
23 class Query implements RouteInterface
25 /**
26 * Default values.
28 * @var array
30 protected $defaults;
32 /**
33 * List of assembled parameters.
35 * @var array
37 protected $assembledParams = array();
39 /**
40 * Create a new wildcard route.
42 * @param array $defaults
44 public function __construct(array $defaults = array())
46 /**
47 * Legacy purposes only, to prevent code that uses it from breaking.
49 trigger_error('Query route deprecated as of ZF 2.1.4; use the "query" option of the HTTP router\'s assembling method instead', E_USER_DEPRECATED);
50 $this->defaults = $defaults;
53 /**
54 * factory(): defined by RouteInterface interface.
56 * @see \Zend\Mvc\Router\RouteInterface::factory()
57 * @param array|Traversable $options
58 * @return Query
59 * @throws Exception\InvalidArgumentException
61 public static function factory($options = array())
63 if ($options instanceof Traversable) {
64 $options = ArrayUtils::iteratorToArray($options);
65 } elseif (!is_array($options)) {
66 throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options');
69 if (!isset($options['defaults'])) {
70 $options['defaults'] = array();
73 return new static($options['defaults']);
76 /**
77 * match(): defined by RouteInterface interface.
79 * @see \Zend\Mvc\Router\RouteInterface::match()
80 * @param Request $request
81 * @return RouteMatch
83 public function match(Request $request)
85 // We don't merge the query parameters into the rotue match here because
86 // of possible security problems. Use the Query object instead which is
87 // included in the Request object.
88 return new RouteMatch($this->defaults);
91 /**
92 * Recursively urldecodes keys and values from an array
94 * @param array $array
95 * @return array
97 protected function recursiveUrldecode(array $array)
99 $matches = array();
101 foreach ($array as $key => $value) {
102 if (is_array($value)) {
103 $matches[urldecode($key)] = $this->recursiveUrldecode($value);
104 } else {
105 $matches[urldecode($key)] = urldecode($value);
109 return $matches;
113 * assemble(): Defined by RouteInterface interface.
115 * @see \Zend\Mvc\Router\RouteInterface::assemble()
116 * @param array $params
117 * @param array $options
118 * @return mixed
120 public function assemble(array $params = array(), array $options = array())
122 $mergedParams = array_merge($this->defaults, $params);
123 $this->assembledParams = array();
125 if (isset($options['uri']) && count($mergedParams)) {
126 foreach ($mergedParams as $key => $value) {
127 $this->assembledParams[] = $key;
130 $options['uri']->setQuery($mergedParams);
133 // A query does not contribute to the path, thus nothing is returned.
134 return '';
138 * getAssembledParams(): defined by RouteInterface interface.
140 * @see RouteInterface::getAssembledParams
141 * @return array
143 public function getAssembledParams()
145 return $this->assembledParams;