Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
PendingFileCollection.php
1<?php
2
4
5class PendingFileCollection implements \IteratorAggregate
6{
10 private array $files = [];
11
12 public function add(PendingFile $pendingFile): void
13 {
14 $this->files[$pendingFile->getId()] = $pendingFile;
15 }
16
17 public function get(string $tempFileId): ?PendingFile
18 {
19 return $this->files[$tempFileId] ?? null;
20 }
21
22 public function getByFileId(int $fileId): ?PendingFile
23 {
24 foreach ($this->files as $file)
25 {
26 if ($file->getFileId() === $fileId)
27 {
28 return $file;
29 }
30 }
31
32 return null;
33 }
34
38 public function getFileIds(): array
39 {
40 $ids = [];
41 foreach ($this->files as $file)
42 {
43 $id = $file->getFileId();
44 if ($id !== null)
45 {
46 $ids[] = $id;
47 }
48 }
49
50 return $ids;
51 }
52
53 public function makePersistent(): void
54 {
55 foreach ($this->files as $file)
56 {
57 $file->makePersistent();
58 }
59 }
60
61 public function remove(): void
62 {
63 foreach ($this->files as $file)
64 {
65 $file->remove();
66 }
67 }
68
72 public function getAll(): array
73 {
74 return $this->files;
75 }
76
80 public function getIterator(): \ArrayIterator
81 {
82 return new \ArrayIterator($this->files);
83 }
84}