PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
jetformbuilder / includes / classes / resources / file-collection.php

file-collection.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at includes/classes/resources/file-collection.php

84 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace Jet_Form_Builder\Classes\Resources;
5
6 use Jet_Form_Builder\Classes\Arrayable\Collection;
7
8 // If this file is called directly, abort.
9 if ( ! defined( 'WPINC' ) ) {
10 die;
11 }
12
13 class File_Collection extends Collection implements Media_Block_Value, Has_Error_File {
14
15 public function push( array $file ): bool {
16 try {
17 $file = new File( $file );
18 } catch ( Sanitize_File_Exception $exception ) {
19 return false;
20 }
21 $this->add( $file );
22
23 return true;
24 }
25
26 public function push_files( array $files ): File_Collection {
27 foreach ( $files as $file ) {
28 $this->push( $file );
29 }
30
31 return $this;
32 }
33
34 public function has_error(): bool {
35 /** @var File $file */
36 foreach ( $this as $file ) {
37 if ( $file->has_error() ) {
38 return true;
39 }
40 }
41
42 return false;
43 }
44
45 /*
46 * Realisation of
47 * \Jet_Form_Builder\Classes\Resources\Media_Block_Value
48 */
49
50 /**
51 * @return string
52 */
53 public function get_attachment_id(): string {
54 return '';
55 }
56
57 /**
58 * @return string
59 */
60 public function get_attachment_url(): string {
61 $urls = array();
62
63 foreach ( $this as $file ) {
64 $urls[] = $file->get_attachment_url();
65 }
66
67 return implode( ',', $urls );
68 }
69
70 /**
71 * @return array
72 */
73 public function get_attachment_both(): array {
74 return array();
75 }
76
77 /**
78 * @return array
79 */
80 public function get_attachment_ids(): array {
81 return array();
82 }
83 }
84