4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Routing;
15 * CompiledRoutes are returned by the RouteCompiler class.
17 * @author Fabien Potencier <fabien@symfony.com>
19 class CompiledRoute implements \Serializable
23 private $staticPrefix;
25 private $pathVariables;
26 private $hostVariables;
33 * @param string $staticPrefix The static prefix of the compiled route
34 * @param string $regex The regular expression to use to match this route
35 * @param array $tokens An array of tokens to use to generate URL for this route
36 * @param array $pathVariables An array of path variables
37 * @param string|null $hostRegex Host regex
38 * @param array $hostTokens Host tokens
39 * @param array $hostVariables An array of host variables
40 * @param array $variables An array of variables (variables defined in the path and in the host patterns)
42 public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
44 $this->staticPrefix = (string) $staticPrefix;
45 $this->regex = $regex;
46 $this->tokens = $tokens;
47 $this->pathVariables = $pathVariables;
48 $this->hostRegex = $hostRegex;
49 $this->hostTokens = $hostTokens;
50 $this->hostVariables = $hostVariables;
51 $this->variables = $variables;
57 public function serialize()
59 return serialize(array(
60 'vars' => $this->variables,
61 'path_prefix' => $this->staticPrefix,
62 'path_regex' => $this->regex,
63 'path_tokens' => $this->tokens,
64 'path_vars' => $this->pathVariables,
65 'host_regex' => $this->hostRegex,
66 'host_tokens' => $this->hostTokens,
67 'host_vars' => $this->hostVariables,
74 public function unserialize($serialized)
76 $data = unserialize($serialized);
77 $this->variables = $data['vars'];
78 $this->staticPrefix = $data['path_prefix'];
79 $this->regex = $data['path_regex'];
80 $this->tokens = $data['path_tokens'];
81 $this->pathVariables = $data['path_vars'];
82 $this->hostRegex = $data['host_regex'];
83 $this->hostTokens = $data['host_tokens'];
84 $this->hostVariables = $data['host_vars'];
88 * Returns the static prefix.
90 * @return string The static prefix
92 public function getStaticPrefix()
94 return $this->staticPrefix;
100 * @return string The regex
102 public function getRegex()
108 * Returns the host regex.
110 * @return string|null The host regex or null
112 public function getHostRegex()
114 return $this->hostRegex;
118 * Returns the tokens.
120 * @return array The tokens
122 public function getTokens()
124 return $this->tokens;
128 * Returns the host tokens.
130 * @return array The tokens
132 public function getHostTokens()
134 return $this->hostTokens;
138 * Returns the variables.
140 * @return array The variables
142 public function getVariables()
144 return $this->variables;
148 * Returns the path variables.
150 * @return array The variables
152 public function getPathVariables()
154 return $this->pathVariables;
158 * Returns the host variables.
160 * @return array The variables
162 public function getHostVariables()
164 return $this->hostVariables;