Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
options.php
1
<?php
9
namespace
Bitrix\Main\Routing
;
10
15
class
Options
16
{
17
// could be auto-generated by Reflection and prop-prefixes
18
public
static
$optionList
= [
19
'methods'
,
'middleware'
,
'prefix'
,
'name'
,
'domain'
,
'where'
,
'default'
20
];
21
22
protected
$methods
= [];
23
24
protected
$middleware
= [];
25
26
protected
$prefix
;
27
28
protected
$parentPrefixes
= [];
29
30
protected
$name
;
31
32
protected
$parentNames
= [];
33
34
protected
$domain
;
35
36
protected
$where
= [];
37
38
protected
$default
= [];
39
43
public
function
mergeWith
($anotherOptions)
44
{
45
$this->
where
= array_merge($this->
where
, $anotherOptions->where);
46
$this->
middleware
= array_merge($this->
middleware
, $anotherOptions->middleware);
47
48
if
($anotherOptions->prefix !=
''
)
49
{
50
$this->parentPrefixes[] = $anotherOptions->prefix;
51
}
52
53
if
($anotherOptions->name !=
''
)
54
{
55
$this->parentNames[] = $anotherOptions->name;
56
}
57
}
58
59
public
function
methods
(
$methods
)
60
{
61
$this->
methods
=
$methods
;
62
}
63
67
public
function
getMethods
()
68
{
69
return
$this->methods
;
70
}
71
72
public
function
middleware
(
$middleware
)
73
{
74
if
(is_array(
$middleware
))
75
{
76
$this->
middleware
= array_merge($this->
middleware
,
$middleware
);
77
}
78
else
79
{
80
$this->
middleware
[] =
$middleware
;
81
}
82
}
83
84
public
function
prefix
(
$prefix
)
85
{
86
$this->
prefix
=
$prefix
;
87
}
88
89
public
function
hasPrefix
()
90
{
91
return
$this->
prefix
!=
''
|| !empty($this->parentPrefixes);
92
}
93
94
public
function
getFullPrefix
()
95
{
96
// concat parentPrefixes with this prefix
97
$prefixes = $this->parentPrefixes ?: [];
98
99
if
($this->
prefix
!=
''
)
100
{
101
$prefixes[] =
$this->prefix
;
102
}
103
104
105
return
'/'
.join(
'/'
, $prefixes);
106
}
107
108
public
function
name
(
$name
)
109
{
110
$this->
name
=
$name
;
111
}
112
113
public
function
hasName
()
114
{
115
return
$this->
name
!=
''
;
116
}
117
118
public
function
getFullName
()
119
{
120
if
($this->
name
==
''
)
121
{
122
// route should have its own name
123
return
''
;
124
}
125
126
// concat parentPrefixes with this prefix
127
$parts = $this->parentNames ?: [];
128
$parts[] =
$this->name
;
129
130
return
join(
''
, $parts);
131
}
132
136
public
function
domain
(
$domain
)
137
{
138
$this->
domain
=
$domain
;
139
}
140
141
public
function
where
($parameter, $pattern)
142
{
143
$this->
where
[$parameter] = $pattern;
144
}
145
146
public
function
hasWhere
($parameter)
147
{
148
return
array_key_exists($parameter, $this->
where
);
149
}
150
151
public
function
getWhere
($parameter =
null
)
152
{
153
if
($parameter ===
null
)
154
{
155
return
$this->where
;
156
}
157
else
158
{
159
return
$this->
where
[$parameter];
160
}
161
}
162
163
public
function
default
($parameter, $value)
164
{
165
$this->
default
[$parameter] = $value;
166
}
167
168
public
function
hasDefault
($parameter)
169
{
170
return
array_key_exists($parameter, $this->
default
);
171
}
172
173
public
function
getDefault
($parameter =
null
)
174
{
175
if
($parameter ===
null
)
176
{
177
return
$this->default
;
178
}
179
else
180
{
181
return
$this->
default
[$parameter];
182
}
183
}
184
189
public
function
clearCurrent
()
190
{
191
$this->
prefix
=
null
;
192
$this->
name
=
null
;
193
}
194
}
Bitrix\Main\Routing\Options
Definition
options.php:16
Bitrix\Main\Routing\Options\where
where($parameter, $pattern)
Definition
options.php:141
Bitrix\Main\Routing\Options\$prefix
$prefix
Definition
options.php:26
Bitrix\Main\Routing\Options\mergeWith
mergeWith($anotherOptions)
Definition
options.php:43
Bitrix\Main\Routing\Options\getFullName
getFullName()
Definition
options.php:118
Bitrix\Main\Routing\Options\$middleware
$middleware
Definition
options.php:24
Bitrix\Main\Routing\Options\hasWhere
hasWhere($parameter)
Definition
options.php:146
Bitrix\Main\Routing\Options\clearCurrent
clearCurrent()
Definition
options.php:189
Bitrix\Main\Routing\Options\middleware
middleware($middleware)
Definition
options.php:72
Bitrix\Main\Routing\Options\domain
domain($domain)
Definition
options.php:136
Bitrix\Main\Routing\Options\getFullPrefix
getFullPrefix()
Definition
options.php:94
Bitrix\Main\Routing\Options\$methods
$methods
Definition
options.php:22
Bitrix\Main\Routing\Options\$optionList
static $optionList
Definition
options.php:18
Bitrix\Main\Routing\Options\getWhere
getWhere($parameter=null)
Definition
options.php:151
Bitrix\Main\Routing\Options\hasPrefix
hasPrefix()
Definition
options.php:89
Bitrix\Main\Routing\Options\getDefault
getDefault($parameter=null)
Definition
options.php:173
Bitrix\Main\Routing\Options\hasDefault
hasDefault($parameter)
Definition
options.php:168
Bitrix\Main\Routing\Options\$default
$default
Definition
options.php:38
Bitrix\Main\Routing\Options\$parentNames
$parentNames
Definition
options.php:32
Bitrix\Main\Routing\Options\$name
$name
Definition
options.php:30
Bitrix\Main\Routing\Options\getMethods
getMethods()
Definition
options.php:67
Bitrix\Main\Routing\Options\hasName
hasName()
Definition
options.php:113
Bitrix\Main\Routing\Options\name
name($name)
Definition
options.php:108
Bitrix\Main\Routing\Options\$where
$where
Definition
options.php:36
Bitrix\Main\Routing\Options\prefix
prefix($prefix)
Definition
options.php:84
Bitrix\Main\Routing\Options\$parentPrefixes
$parentPrefixes
Definition
options.php:28
Bitrix\Main\Routing\Options\methods
methods($methods)
Definition
options.php:59
Bitrix\Main\Routing\Options\$domain
$domain
Definition
options.php:34
Bitrix\Main\Routing
Definition
_config.php:3
modules
main
lib
routing
options.php
Создано системой
1.10.0