Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 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
     * @param string      $staticPrefix  The static prefix of the compiled route
32
     * @param string      $regex         The regular expression to use to match this route
33
     * @param array       $tokens        An array of tokens to use to generate URL for this route
34
     * @param array       $pathVariables An array of path variables
35
     * @param string|null $hostRegex     Host regex
36
     * @param array       $hostTokens    Host tokens
37
     * @param array       $hostVariables An array of host variables
38
     * @param array       $variables     An array of variables (variables defined in the path and in the host patterns)
39
     */
40
    public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = [], array $hostVariables = [], array $variables = [])
41
    {
42
        $this->staticPrefix = $staticPrefix;
43
        $this->regex = $regex;
44
        $this->tokens = $tokens;
45
        $this->pathVariables = $pathVariables;
46
        $this->hostRegex = $hostRegex;
47
        $this->hostTokens = $hostTokens;
48
        $this->hostVariables = $hostVariables;
49
        $this->variables = $variables;
50
    }
51
 
52
    public function __serialize(): array
53
    {
54
        return [
55
            'vars' => $this->variables,
56
            'path_prefix' => $this->staticPrefix,
57
            'path_regex' => $this->regex,
58
            'path_tokens' => $this->tokens,
59
            'path_vars' => $this->pathVariables,
60
            'host_regex' => $this->hostRegex,
61
            'host_tokens' => $this->hostTokens,
62
            'host_vars' => $this->hostVariables,
63
        ];
64
    }
65
 
66
    /**
67
     * @internal
68
     */
69
    final public function serialize(): string
70
    {
71
        return serialize($this->__serialize());
72
    }
73
 
74
    public function __unserialize(array $data): void
75
    {
76
        $this->variables = $data['vars'];
77
        $this->staticPrefix = $data['path_prefix'];
78
        $this->regex = $data['path_regex'];
79
        $this->tokens = $data['path_tokens'];
80
        $this->pathVariables = $data['path_vars'];
81
        $this->hostRegex = $data['host_regex'];
82
        $this->hostTokens = $data['host_tokens'];
83
        $this->hostVariables = $data['host_vars'];
84
    }
85
 
86
    /**
87
     * @internal
88
     */
89
    final public function unserialize($serialized)
90
    {
91
        $this->__unserialize(unserialize($serialized, ['allowed_classes' => false]));
92
    }
93
 
94
    /**
95
     * Returns the static prefix.
96
     *
97
     * @return string The static prefix
98
     */
99
    public function getStaticPrefix()
100
    {
101
        return $this->staticPrefix;
102
    }
103
 
104
    /**
105
     * Returns the regex.
106
     *
107
     * @return string The regex
108
     */
109
    public function getRegex()
110
    {
111
        return $this->regex;
112
    }
113
 
114
    /**
115
     * Returns the host regex.
116
     *
117
     * @return string|null The host regex or null
118
     */
119
    public function getHostRegex()
120
    {
121
        return $this->hostRegex;
122
    }
123
 
124
    /**
125
     * Returns the tokens.
126
     *
127
     * @return array The tokens
128
     */
129
    public function getTokens()
130
    {
131
        return $this->tokens;
132
    }
133
 
134
    /**
135
     * Returns the host tokens.
136
     *
137
     * @return array The tokens
138
     */
139
    public function getHostTokens()
140
    {
141
        return $this->hostTokens;
142
    }
143
 
144
    /**
145
     * Returns the variables.
146
     *
147
     * @return array The variables
148
     */
149
    public function getVariables()
150
    {
151
        return $this->variables;
152
    }
153
 
154
    /**
155
     * Returns the path variables.
156
     *
157
     * @return array The variables
158
     */
159
    public function getPathVariables()
160
    {
161
        return $this->pathVariables;
162
    }
163
 
164
    /**
165
     * Returns the host variables.
166
     *
167
     * @return array The variables
168
     */
169
    public function getHostVariables()
170
    {
171
        return $this->hostVariables;
172
    }
173
}