Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
base.php
1
<?php
2
3
namespace
Bitrix\Rest\Configuration\DataProvider\Http
;
4
5
use
Bitrix\Main\SystemException
;
6
use
Bitrix\Main\LoaderException
;
7
use
Bitrix\Main\IO\File
;
8
use
Bitrix\Main\IO\FileNotFoundException
;
9
use
Bitrix\Rest\Configuration\DataProvider\ProviderBase
;
10
11
class
Base
extends
ProviderBase
12
{
18
public
function
__construct
(array $setting)
19
{
20
parent::__construct($setting);
21
}
22
26
public
function
set
()
27
{
28
throw
new
SystemException
(
29
'This method isn\'t supported'
,
30
'ERROR_METHOD'
31
);
32
}
33
40
public
function
get
($path): array
41
{
42
$result =
null
;
43
if
($path)
44
{
45
$fileInfo = \CFile::MakeFileArray($path);
46
if
(is_array($fileInfo) && File::isFileExists($fileInfo[
'tmp_name'
]))
47
{
48
preg_match(
"/\/([a-zA-Z0-9_-]+)\.[a-zA-Z0-9_-]+$/"
, $path, $matches);
49
$name = $matches[1] ??
null
;
50
51
$file =
new
File
($fileInfo[
'tmp_name'
]);
52
try
53
{
54
$result = [
55
'DATA'
=> $file->getContents(),
56
'FILE_NAME'
=> $name,
57
];
58
}
59
catch
(
FileNotFoundException
$exception)
60
{
61
$result =
null
;
62
}
63
}
64
}
65
66
return
$result;
67
}
68
74
public
function
addFiles
(array $files)
75
{
76
throw
new
SystemException
(
77
'This method isn\'t supported'
,
78
'ERROR_METHOD'
79
);
80
}
81
}
Bitrix\Main\IO\File
Definition
file.php:7
Bitrix\Main\IO\FileNotFoundException
Definition
ioexception.php:45
Bitrix\Main\LoaderException
Definition
loader.php:582
Bitrix\Main\SystemException
Definition
exception.php:8
Bitrix\Rest\Configuration\DataProvider\Http\Base
Definition
base.php:12
Bitrix\Rest\Configuration\DataProvider\Http\Base\__construct
__construct(array $setting)
Definition
base.php:18
Bitrix\Rest\Configuration\DataProvider\Http\Base\addFiles
addFiles(array $files)
Definition
base.php:74
Bitrix\Rest\Configuration\DataProvider\ProviderBase
Definition
providerbase.php:15
Bitrix\Rest\Configuration\DataProvider\Http
Definition
base.php:3
modules
rest
lib
configuration
dataprovider
http
base.php
Создано системой
1.10.0