| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
class sfRequestRoute extends sfRoute |
|---|
| 22 |
{ |
|---|
| 23 |
|
|---|
| 24 |
* Returns true if the URL matches this route, false otherwise. |
|---|
| 25 |
* |
|---|
| 26 |
* @param string $url The URL |
|---|
| 27 |
* @param array $context The context |
|---|
| 28 |
* |
|---|
| 29 |
* @return array An array of parameters |
|---|
| 30 |
*/ |
|---|
| 31 |
public function matchesUrl($url, $context = array()) |
|---|
| 32 |
{ |
|---|
| 33 |
if (false === $parameters = parent::matchesUrl($url, $context)) |
|---|
| 34 |
{ |
|---|
| 35 |
return false; |
|---|
| 36 |
} |
|---|
| 37 |
|
|---|
| 38 |
if (!isset($this->requirements['sf_method'])) |
|---|
| 39 |
{ |
|---|
| 40 |
$this->requirements['sf_method'] = array('get', 'head'); |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
$methods = is_array($this->requirements['sf_method']) ? $this->requirements['sf_method'] : array($this->requirements['sf_method']); |
|---|
| 45 |
foreach ($methods as $method) |
|---|
| 46 |
{ |
|---|
| 47 |
if (0 == strcasecmp($method, $context['method'])) |
|---|
| 48 |
{ |
|---|
| 49 |
return $parameters; |
|---|
| 50 |
} |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
return false; |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
* Returns true if the parameters matches this route, false otherwise. |
|---|
| 58 |
* |
|---|
| 59 |
* @param mixed $params The parameters |
|---|
| 60 |
* @param array $context The context |
|---|
| 61 |
* |
|---|
| 62 |
* @return Boolean true if the parameters matches this route, false otherwise. |
|---|
| 63 |
*/ |
|---|
| 64 |
public function matchesParameters($params, $context = array()) |
|---|
| 65 |
{ |
|---|
| 66 |
if (isset($params['sf_method'])) |
|---|
| 67 |
{ |
|---|
| 68 |
if (!isset($this->requirements['sf_method'])) |
|---|
| 69 |
{ |
|---|
| 70 |
$this->requirements['sf_method'] = 'get'; |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
if ($this->requirements['sf_method'] != $params['sf_method']) |
|---|
| 75 |
{ |
|---|
| 76 |
return false; |
|---|
| 77 |
} |
|---|
| 78 |
|
|---|
| 79 |
unset($params['sf_method']); |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
return parent::matchesParameters($params, $context); |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
* Generates a URL from the given parameters. |
|---|
| 87 |
* |
|---|
| 88 |
* @param mixed $params The parameter values |
|---|
| 89 |
* @param array $context The context |
|---|
| 90 |
* @param Boolean $absolute Whether to generate an absolute URL |
|---|
| 91 |
* |
|---|
| 92 |
* @return string The generated URL |
|---|
| 93 |
*/ |
|---|
| 94 |
public function generate($params = array(), $context = array(), $absolute = false) |
|---|
| 95 |
{ |
|---|
| 96 |
unset($params['sf_method']); |
|---|
| 97 |
|
|---|
| 98 |
return parent::generate($params, $context, $absolute); |
|---|
| 99 |
} |
|---|
| 100 |
} |
|---|
| 101 |
|
|---|