Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
base.php
1
<?php
2
3
namespace
Bitrix\Rest\Url
;
4
5
use \Bitrix\Main\Web\Uri;
6
7
class
Base
8
{
9
protected
$directory
=
''
;
10
protected
$pages
= [];
11
protected
static
$instance
;
12
13
final
public
static
function
getInstance
()
14
{
15
if
(!isset(static::$instance))
16
{
17
static::$instance =
new
static
();
18
}
19
return
static::$instance;
20
}
21
22
protected
function
getDir
()
23
{
24
return
SITE_DIR.$this->directory;
25
}
26
27
protected
function
getReplaced
(
string
$url, $replace =
null
, $subject =
null
)
28
{
29
if
(!is_null($replace) && !is_null($subject))
30
{
31
$url = str_replace($replace, $subject, $url);
32
}
33
34
return
$url;
35
}
36
37
protected
function
addParams
($url, $params)
38
{
39
if
(is_array($params))
40
{
41
$uri =
new
Uri
($url);
42
$uri->addParams($params);
43
$url = $uri->getUri();
44
}
45
46
return
$url;
47
}
48
49
protected
function
getUrl
($page, $replace =
null
, $subject =
null
, $query =
null
)
50
{
51
$url =
null
;
52
if
(array_key_exists($page, $this->pages))
53
{
54
$url = $this->
getDir
().$this->pages[$page];
55
56
if
(!is_null($replace) && !is_null($subject))
57
{
58
$url = $this->
getReplaced
($url, $replace, $subject);
59
}
60
$url = $this->
getReplaced
($url,
'//'
,
'/'
);
61
62
if
(is_array($query))
63
{
64
$url = $this->
addParams
($url, $query);
65
}
66
}
67
68
return
$url;
69
}
70
71
}
Bitrix\Main\Web\Uri
Definition
uri.php:17
Bitrix\Rest\Url\Base
Definition
base.php:8
Bitrix\Rest\Url\Base\addParams
addParams($url, $params)
Definition
base.php:37
Bitrix\Rest\Url\Base\$directory
$directory
Definition
base.php:9
Bitrix\Rest\Url\Base\$pages
$pages
Definition
base.php:10
Bitrix\Rest\Url\Base\getReplaced
getReplaced(string $url, $replace=null, $subject=null)
Definition
base.php:27
Bitrix\Rest\Url\Base\getUrl
getUrl($page, $replace=null, $subject=null, $query=null)
Definition
base.php:49
Bitrix\Rest\Url\Base\getDir
getDir()
Definition
base.php:22
Bitrix\Rest\Url\Base\getInstance
static getInstance()
Definition
base.php:13
Bitrix\Rest\Url\Base\$instance
static $instance
Definition
base.php:11
Bitrix\Rest\Url
Definition
base.php:3
modules
rest
lib
url
base.php
Создано системой
1.10.0