Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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 array $variables;
22
    private array $tokens;
23
    private string $staticPrefix;
24
    private string $regex;
25
    private array $pathVariables;
26
    private array $hostVariables;
27
    private ?string $hostRegex;
28
    private array $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
        throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
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(string $serialized)
90
    {
91
        $this->__unserialize(unserialize($serialized, ['allowed_classes' => false]));
92
    }
93
 
94
    /**
95
     * Returns the static prefix.
96
     */
97
    public function getStaticPrefix(): string
98
    {
99
        return $this->staticPrefix;
100
    }
101
 
102
    /**
103
     * Returns the regex.
104
     */
105
    public function getRegex(): string
106
    {
107
        return $this->regex;
108
    }
109
 
110
    /**
111
     * Returns the host regex.
112
     */
113
    public function getHostRegex(): ?string
114
    {
115
        return $this->hostRegex;
116
    }
117
 
118
    /**
119
     * Returns the tokens.
120
     */
121
    public function getTokens(): array
122
    {
123
        return $this->tokens;
124
    }
125
 
126
    /**
127
     * Returns the host tokens.
128
     */
129
    public function getHostTokens(): array
130
    {
131
        return $this->hostTokens;
132
    }
133
 
134
    /**
135
     * Returns the variables.
136
     */
137
    public function getVariables(): array
138
    {
139
        return $this->variables;
140
    }
141
 
142
    /**
143
     * Returns the path variables.
144
     */
145
    public function getPathVariables(): array
146
    {
147
        return $this->pathVariables;
148
    }
149
 
150
    /**
151
     * Returns the host variables.
152
     */
153
    public function getHostVariables(): array
154
    {
155
        return $this->hostVariables;
156
    }
157
}