3eca9ecd8b010b0fac851d0f938631b042da1304
[yaffs-website] / vendor / symfony / routing / CompiledRoute.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Routing;
13
14 /**
15  * CompiledRoutes are returned by the RouteCompiler class.
16  *
17  * @author Fabien Potencier <fabien@symfony.com>
18  */
19 class CompiledRoute implements \Serializable
20 {
21     private $variables;
22     private $tokens;
23     private $staticPrefix;
24     private $regex;
25     private $pathVariables;
26     private $hostVariables;
27     private $hostRegex;
28     private $hostTokens;
29
30     /**
31      * Constructor.
32      *
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)
41      */
42     public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
43     {
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;
52     }
53
54     /**
55      * {@inheritdoc}
56      */
57     public function serialize()
58     {
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,
68         ));
69     }
70
71     /**
72      * {@inheritdoc}
73      */
74     public function unserialize($serialized)
75     {
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'];
85     }
86
87     /**
88      * Returns the static prefix.
89      *
90      * @return string The static prefix
91      */
92     public function getStaticPrefix()
93     {
94         return $this->staticPrefix;
95     }
96
97     /**
98      * Returns the regex.
99      *
100      * @return string The regex
101      */
102     public function getRegex()
103     {
104         return $this->regex;
105     }
106
107     /**
108      * Returns the host regex.
109      *
110      * @return string|null The host regex or null
111      */
112     public function getHostRegex()
113     {
114         return $this->hostRegex;
115     }
116
117     /**
118      * Returns the tokens.
119      *
120      * @return array The tokens
121      */
122     public function getTokens()
123     {
124         return $this->tokens;
125     }
126
127     /**
128      * Returns the host tokens.
129      *
130      * @return array The tokens
131      */
132     public function getHostTokens()
133     {
134         return $this->hostTokens;
135     }
136
137     /**
138      * Returns the variables.
139      *
140      * @return array The variables
141      */
142     public function getVariables()
143     {
144         return $this->variables;
145     }
146
147     /**
148      * Returns the path variables.
149      *
150      * @return array The variables
151      */
152     public function getPathVariables()
153     {
154         return $this->pathVariables;
155     }
156
157     /**
158      * Returns the host variables.
159      *
160      * @return array The variables
161      */
162     public function getHostVariables()
163     {
164         return $this->hostVariables;
165     }
166 }