@@ -49,6 +49,11 @@ class FileUploader
4949 */
5050 private $ scope ;
5151
52+ /**
53+ * @var string[]
54+ */
55+ private array $ validInputTypes ;
56+
5257 /**
5358 * @param CustomerMetadataInterface $customerMetadataService
5459 * @param AddressMetadataInterface $addressMetadataService
@@ -57,6 +62,7 @@ class FileUploader
5762 * @param AttributeMetadataInterface $attributeMetadata
5863 * @param string $entityTypeCode
5964 * @param string $scope
65+ * @param array|null $validInputTypes
6066 */
6167 public function __construct (
6268 CustomerMetadataInterface $ customerMetadataService ,
@@ -65,7 +71,8 @@ public function __construct(
6571 FileProcessorFactory $ fileProcessorFactory ,
6672 AttributeMetadataInterface $ attributeMetadata ,
6773 $ entityTypeCode ,
68- $ scope
74+ $ scope ,
75+ ?array $ validInputTypes = ['file ' , 'image ' ]
6976 ) {
7077 $ this ->customerMetadataService = $ customerMetadataService ;
7178 $ this ->addressMetadataService = $ addressMetadataService ;
@@ -74,6 +81,7 @@ public function __construct(
7481 $ this ->attributeMetadata = $ attributeMetadata ;
7582 $ this ->entityTypeCode = $ entityTypeCode ;
7683 $ this ->scope = $ scope ;
84+ $ this ->validInputTypes = $ validInputTypes ;
7785 }
7886
7987 /**
@@ -83,7 +91,7 @@ public function __construct(
8391 */
8492 public function validate ()
8593 {
86- if (!in_array ($ this ->attributeMetadata ->getFrontendInput (), [ ' file ' , ' image ' ] )) {
94+ if (!in_array ($ this ->attributeMetadata ->getFrontendInput (), $ this -> validInputTypes )) {
8795 return [
8896 __ ('"%1" is not a valid input to accept file uploads. ' , $ this ->attributeMetadata ->getFrontendInput ())
8997 ];
0 commit comments