file-collection.php
3 years ago
file-tools.php
3 years ago
file.php
3 years ago
media-block-value.php
3 years ago
sanitize-file-exception.php
3 years ago
upload-dir.php
3 years ago
upload-exception.php
3 years ago
upload-permission-exception.php
3 years ago
uploaded-collection.php
3 years ago
uploaded-file-path.php
3 years ago
uploaded-file.php
3 years ago
uploaded-collection.php
77 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Classes\Resources; |
| 5 | |
| 6 | |
| 7 | class Uploaded_Collection implements Media_Block_Value, Uploaded_File_Path { |
| 8 | |
| 9 | /** @var Uploaded_File[] */ |
| 10 | protected $uploads; |
| 11 | |
| 12 | public function __construct( array $uploads ) { |
| 13 | $this->uploads = $uploads; |
| 14 | } |
| 15 | |
| 16 | /* |
| 17 | * Realisation of |
| 18 | * \Jet_Form_Builder\Classes\Resources\Media_Block_Value |
| 19 | */ |
| 20 | |
| 21 | /** |
| 22 | * @return string |
| 23 | */ |
| 24 | public function get_attachment_id(): string { |
| 25 | $ids = array(); |
| 26 | |
| 27 | foreach ( $this->uploads as $upload ) { |
| 28 | $ids[] = $upload->get_attachment_id(); |
| 29 | } |
| 30 | |
| 31 | return implode( ',', $ids ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @return string |
| 36 | */ |
| 37 | public function get_attachment_url(): string { |
| 38 | $urls = array(); |
| 39 | |
| 40 | foreach ( $this->uploads as $upload ) { |
| 41 | $urls[] = $upload->get_attachment_url(); |
| 42 | } |
| 43 | |
| 44 | return implode( ',', $urls ); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * @return array |
| 49 | */ |
| 50 | public function get_attachment_both(): array { |
| 51 | $both = array(); |
| 52 | |
| 53 | foreach ( $this->uploads as $upload ) { |
| 54 | $both[] = $upload->get_attachment_both(); |
| 55 | } |
| 56 | |
| 57 | return $both; |
| 58 | } |
| 59 | |
| 60 | /* |
| 61 | * Realisation of |
| 62 | * \Jet_Form_Builder\Classes\Resources\Uploaded_File_Path |
| 63 | */ |
| 64 | |
| 65 | /** |
| 66 | * @return string |
| 67 | */ |
| 68 | public function get_attachment_file(): string { |
| 69 | $files = array(); |
| 70 | |
| 71 | foreach ( $this->uploads as $upload ) { |
| 72 | $files[] = $upload->get_attachment_file(); |
| 73 | } |
| 74 | |
| 75 | return implode( ',', $files ); |
| 76 | } |
| 77 | } |