-
Notifications
You must be signed in to change notification settings - Fork 181
/
Copy pathsfNoRouting.class.php
107 lines (92 loc) · 2.41 KB
/
sfNoRouting.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* sfNoRouting class is a very simple routing class that uses GET parameters.
*
* @author Fabien Potencier <[email protected]>
*
* @version SVN: $Id: sfNoRouting.class.php 20566 2009-07-29 07:04:01Z fabien $
*/
class sfNoRouting extends sfRouting
{
/**
* @see sfRouting
*/
public function getCurrentInternalUri($with_route_name = false)
{
$parameters = $this->mergeArrays($this->defaultParameters, $_GET);
$action = sprintf('%s/%s', $parameters['module'], $parameters['action']);
// other parameters
unset($parameters['module'], $parameters['action']);
ksort($parameters);
$parameters = count($parameters) ? '?'.http_build_query($parameters, '', '&') : '';
return sprintf('%s%s', $action, $parameters);
}
/**
* @see sfRouting
*/
public function generate($name, $params = array(), $absolute = false)
{
$parameters = $this->mergeArrays($this->defaultParameters, $params);
if ($this->getDefaultParameter('module') == $parameters['module']) {
unset($parameters['module']);
}
if ($this->getDefaultParameter('action') == $parameters['action']) {
unset($parameters['action']);
}
$parameters = http_build_query($parameters, '', '&');
return $this->fixGeneratedUrl('/'.($parameters ? '?'.$parameters : ''), $absolute);
}
/**
* @see sfRouting
*/
public function parse($url)
{
return array();
}
/**
* @see sfRouting
*/
public function getRoutes()
{
return array();
}
/**
* @see sfRouting
*/
public function getRoute($name)
{
return null;
}
/**
* @see sfRouting
*/
public function setRoutes($routes)
{
return array();
}
/**
* @see sfRouting
*/
public function hasRoutes()
{
return false;
}
/**
* @see sfRouting
*/
public function clearRoutes() {}
protected function mergeArrays($arr1, $arr2)
{
foreach ($arr2 as $key => $value) {
$arr1[$key] = $value;
}
return $arr1;
}
}