Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
PendingFile.php
1
<?php
2
3
namespace
Bitrix\UI\FileUploader
;
4
5
use
Bitrix\Main\Error
;
6
use
Bitrix\Main\ErrorCollection
;
7
8
class
PendingFile
9
{
10
private
string
$id;
11
private
?
TempFile
$tempFile =
null
;
12
private
ErrorCollection
$errors;
13
private
string
$status =
PendingFileStatus::INIT
;
14
15
public
function
__construct
(
string
$id)
16
{
17
$this->
id
= $id;
18
$this->errors =
new
ErrorCollection
();
19
}
20
21
public
function
getId
(): string
22
{
23
return
$this->id;
24
}
25
26
public
function
getGuid
(): ?string
27
{
28
return
$this->tempFile !==
null
? $this->tempFile->getGuid() :
null
;
29
}
30
31
public
function
getFileId
(): ?int
32
{
33
return
$this->
isValid
() && $this->tempFile !==
null
? $this->tempFile->getFileId() :
null
;
34
}
35
36
public
function
setTempFile
(
TempFile
$tempFile): void
37
{
38
$this->status =
PendingFileStatus::PENDING
;
39
$this->tempFile = $tempFile;
40
}
41
42
protected
function
getTempFile
(): ?
TempFile
43
{
44
return
$this->tempFile;
45
}
46
47
public
function
getStatus
(): string
48
{
49
return
$this->status;
50
}
51
52
public
function
makePersistent
(): void
53
{
54
if
($this->
getStatus
() ===
PendingFileStatus::PENDING
)
55
{
56
$this->
getTempFile
()->makePersistent();
57
$this->status =
PendingFileStatus::COMMITTED
;
58
}
59
}
60
61
public
function
remove
(): void
62
{
63
if
($this->
getStatus
() ===
PendingFileStatus::PENDING
)
64
{
65
$this->
getTempFile
()->delete();
66
$this->status =
PendingFileStatus::REMOVED
;
67
}
68
}
69
70
public
function
addError
(
Error
$error): void
71
{
72
$this->status =
PendingFileStatus::ERROR
;
73
$this->errors[] = $error;
74
}
75
76
public
function
getErrors
(): array
77
{
78
return
$this->errors->toArray();
79
}
80
81
public
function
isValid
(): bool
82
{
83
return
(
84
$this->
getStatus
() ===
PendingFileStatus::PENDING
85
|| $this->
getStatus
() ===
PendingFileStatus::COMMITTED
86
);
87
}
88
}
Bitrix\Main\ErrorCollection
Definition
errorcollection.php:14
Bitrix\Main\Error
Definition
error.php:14
Bitrix\UI\FileUploader\PendingFile
Definition
PendingFile.php:9
Bitrix\UI\FileUploader\PendingFile\addError
addError(Error $error)
Definition
PendingFile.php:70
Bitrix\UI\FileUploader\PendingFile\getId
getId()
Definition
PendingFile.php:21
Bitrix\UI\FileUploader\PendingFile\getTempFile
getTempFile()
Definition
PendingFile.php:42
Bitrix\UI\FileUploader\PendingFile\makePersistent
makePersistent()
Definition
PendingFile.php:52
Bitrix\UI\FileUploader\PendingFile\getErrors
getErrors()
Definition
PendingFile.php:76
Bitrix\UI\FileUploader\PendingFile\isValid
isValid()
Definition
PendingFile.php:81
Bitrix\UI\FileUploader\PendingFile\getGuid
getGuid()
Definition
PendingFile.php:26
Bitrix\UI\FileUploader\PendingFile\getStatus
getStatus()
Definition
PendingFile.php:47
Bitrix\UI\FileUploader\PendingFile\setTempFile
setTempFile(TempFile $tempFile)
Definition
PendingFile.php:36
Bitrix\UI\FileUploader\PendingFile\__construct
__construct(string $id)
Definition
PendingFile.php:15
Bitrix\UI\FileUploader\PendingFile\getFileId
getFileId()
Definition
PendingFile.php:31
Bitrix\UI\FileUploader\PendingFileStatus\REMOVED
const REMOVED
Definition
PendingFileStatus.php:11
Bitrix\UI\FileUploader\PendingFileStatus\INIT
const INIT
Definition
PendingFileStatus.php:7
Bitrix\UI\FileUploader\PendingFileStatus\ERROR
const ERROR
Definition
PendingFileStatus.php:9
Bitrix\UI\FileUploader\PendingFileStatus\COMMITTED
const COMMITTED
Definition
PendingFileStatus.php:10
Bitrix\UI\FileUploader\PendingFileStatus\PENDING
const PENDING
Definition
PendingFileStatus.php:8
Bitrix\UI\FileUploader\TempFile
Definition
TempFile.php:11
Bitrix\UI\FileUploader
Definition
CanUploadResult.php:3
modules
ui
lib
FileUploader
PendingFile.php
Создано системой
1.10.0