Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
base.php
1<?php
2
4
10
11class 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}