Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\Routing;
|
Chris@0
|
13
|
Chris@0
|
14 /**
|
Chris@0
|
15 * CompiledRoutes are returned by the RouteCompiler class.
|
Chris@0
|
16 *
|
Chris@0
|
17 * @author Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
18 */
|
Chris@0
|
19 class CompiledRoute implements \Serializable
|
Chris@0
|
20 {
|
Chris@0
|
21 private $variables;
|
Chris@0
|
22 private $tokens;
|
Chris@0
|
23 private $staticPrefix;
|
Chris@0
|
24 private $regex;
|
Chris@0
|
25 private $pathVariables;
|
Chris@0
|
26 private $hostVariables;
|
Chris@0
|
27 private $hostRegex;
|
Chris@0
|
28 private $hostTokens;
|
Chris@0
|
29
|
Chris@0
|
30 /**
|
Chris@0
|
31 * Constructor.
|
Chris@0
|
32 *
|
Chris@0
|
33 * @param string $staticPrefix The static prefix of the compiled route
|
Chris@0
|
34 * @param string $regex The regular expression to use to match this route
|
Chris@0
|
35 * @param array $tokens An array of tokens to use to generate URL for this route
|
Chris@0
|
36 * @param array $pathVariables An array of path variables
|
Chris@0
|
37 * @param string|null $hostRegex Host regex
|
Chris@0
|
38 * @param array $hostTokens Host tokens
|
Chris@0
|
39 * @param array $hostVariables An array of host variables
|
Chris@0
|
40 * @param array $variables An array of variables (variables defined in the path and in the host patterns)
|
Chris@0
|
41 */
|
Chris@0
|
42 public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
|
Chris@0
|
43 {
|
Chris@0
|
44 $this->staticPrefix = (string) $staticPrefix;
|
Chris@0
|
45 $this->regex = $regex;
|
Chris@0
|
46 $this->tokens = $tokens;
|
Chris@0
|
47 $this->pathVariables = $pathVariables;
|
Chris@0
|
48 $this->hostRegex = $hostRegex;
|
Chris@0
|
49 $this->hostTokens = $hostTokens;
|
Chris@0
|
50 $this->hostVariables = $hostVariables;
|
Chris@0
|
51 $this->variables = $variables;
|
Chris@0
|
52 }
|
Chris@0
|
53
|
Chris@0
|
54 /**
|
Chris@0
|
55 * {@inheritdoc}
|
Chris@0
|
56 */
|
Chris@0
|
57 public function serialize()
|
Chris@0
|
58 {
|
Chris@0
|
59 return serialize(array(
|
Chris@0
|
60 'vars' => $this->variables,
|
Chris@0
|
61 'path_prefix' => $this->staticPrefix,
|
Chris@0
|
62 'path_regex' => $this->regex,
|
Chris@0
|
63 'path_tokens' => $this->tokens,
|
Chris@0
|
64 'path_vars' => $this->pathVariables,
|
Chris@0
|
65 'host_regex' => $this->hostRegex,
|
Chris@0
|
66 'host_tokens' => $this->hostTokens,
|
Chris@0
|
67 'host_vars' => $this->hostVariables,
|
Chris@0
|
68 ));
|
Chris@0
|
69 }
|
Chris@0
|
70
|
Chris@0
|
71 /**
|
Chris@0
|
72 * {@inheritdoc}
|
Chris@0
|
73 */
|
Chris@0
|
74 public function unserialize($serialized)
|
Chris@0
|
75 {
|
Chris@0
|
76 $data = unserialize($serialized);
|
Chris@0
|
77 $this->variables = $data['vars'];
|
Chris@0
|
78 $this->staticPrefix = $data['path_prefix'];
|
Chris@0
|
79 $this->regex = $data['path_regex'];
|
Chris@0
|
80 $this->tokens = $data['path_tokens'];
|
Chris@0
|
81 $this->pathVariables = $data['path_vars'];
|
Chris@0
|
82 $this->hostRegex = $data['host_regex'];
|
Chris@0
|
83 $this->hostTokens = $data['host_tokens'];
|
Chris@0
|
84 $this->hostVariables = $data['host_vars'];
|
Chris@0
|
85 }
|
Chris@0
|
86
|
Chris@0
|
87 /**
|
Chris@0
|
88 * Returns the static prefix.
|
Chris@0
|
89 *
|
Chris@0
|
90 * @return string The static prefix
|
Chris@0
|
91 */
|
Chris@0
|
92 public function getStaticPrefix()
|
Chris@0
|
93 {
|
Chris@0
|
94 return $this->staticPrefix;
|
Chris@0
|
95 }
|
Chris@0
|
96
|
Chris@0
|
97 /**
|
Chris@0
|
98 * Returns the regex.
|
Chris@0
|
99 *
|
Chris@0
|
100 * @return string The regex
|
Chris@0
|
101 */
|
Chris@0
|
102 public function getRegex()
|
Chris@0
|
103 {
|
Chris@0
|
104 return $this->regex;
|
Chris@0
|
105 }
|
Chris@0
|
106
|
Chris@0
|
107 /**
|
Chris@0
|
108 * Returns the host regex.
|
Chris@0
|
109 *
|
Chris@0
|
110 * @return string|null The host regex or null
|
Chris@0
|
111 */
|
Chris@0
|
112 public function getHostRegex()
|
Chris@0
|
113 {
|
Chris@0
|
114 return $this->hostRegex;
|
Chris@0
|
115 }
|
Chris@0
|
116
|
Chris@0
|
117 /**
|
Chris@0
|
118 * Returns the tokens.
|
Chris@0
|
119 *
|
Chris@0
|
120 * @return array The tokens
|
Chris@0
|
121 */
|
Chris@0
|
122 public function getTokens()
|
Chris@0
|
123 {
|
Chris@0
|
124 return $this->tokens;
|
Chris@0
|
125 }
|
Chris@0
|
126
|
Chris@0
|
127 /**
|
Chris@0
|
128 * Returns the host tokens.
|
Chris@0
|
129 *
|
Chris@0
|
130 * @return array The tokens
|
Chris@0
|
131 */
|
Chris@0
|
132 public function getHostTokens()
|
Chris@0
|
133 {
|
Chris@0
|
134 return $this->hostTokens;
|
Chris@0
|
135 }
|
Chris@0
|
136
|
Chris@0
|
137 /**
|
Chris@0
|
138 * Returns the variables.
|
Chris@0
|
139 *
|
Chris@0
|
140 * @return array The variables
|
Chris@0
|
141 */
|
Chris@0
|
142 public function getVariables()
|
Chris@0
|
143 {
|
Chris@0
|
144 return $this->variables;
|
Chris@0
|
145 }
|
Chris@0
|
146
|
Chris@0
|
147 /**
|
Chris@0
|
148 * Returns the path variables.
|
Chris@0
|
149 *
|
Chris@0
|
150 * @return array The variables
|
Chris@0
|
151 */
|
Chris@0
|
152 public function getPathVariables()
|
Chris@0
|
153 {
|
Chris@0
|
154 return $this->pathVariables;
|
Chris@0
|
155 }
|
Chris@0
|
156
|
Chris@0
|
157 /**
|
Chris@0
|
158 * Returns the host variables.
|
Chris@0
|
159 *
|
Chris@0
|
160 * @return array The variables
|
Chris@0
|
161 */
|
Chris@0
|
162 public function getHostVariables()
|
Chris@0
|
163 {
|
Chris@0
|
164 return $this->hostVariables;
|
Chris@0
|
165 }
|
Chris@0
|
166 }
|