Skip to content

Commit 93eaa4a

Browse files
committed
Changed mimeTypes argument as optional
1 parent 6cd0d98 commit 93eaa4a

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/lib/FieldType/Image/Type.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,22 @@ class Type extends FieldType implements TranslationContainerInterface
5151
],
5252
];
5353

54-
/** @var array<string> */
55-
private array $mimeTypes;
56-
5754
/** @var \Ibexa\Core\FieldType\Validator[] */
5855
private $validators;
5956

57+
/** @var array<string> */
58+
private array $mimeTypes;
59+
6060
/**
61-
* @param array<string> $mimeTypes
6261
* @param array<\Ibexa\Core\FieldType\Validator> $validators
62+
* @param array<string> $mimeTypes
6363
*/
6464
public function __construct(
65-
array $mimeTypes,
66-
array $validators
65+
array $validators,
66+
array $mimeTypes = []
6767
) {
68-
$this->mimeTypes = $mimeTypes;
6968
$this->validators = $validators;
69+
$this->mimeTypes = $mimeTypes;
7070
}
7171

7272
/**
@@ -247,6 +247,7 @@ public function validateFieldSettings($fieldSettings): array
247247

248248
if (
249249
$name === 'mimeTypes'
250+
&& !empty($this->mimeTypes)
250251
&& !empty(array_diff($value, $this->mimeTypes))
251252
) {
252253
$validationErrors[] = new ValidationError(

tests/lib/FieldType/ImageTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ protected function getMimeTypeDetectorMock()
6868
protected function createFieldTypeUnderTest()
6969
{
7070
$fieldType = new ImageType(
71-
self::MIME_TYPES,
7271
[
7372
$this->getBlackListValidatorMock(),
7473
$this->getImageValidatorMock(),
75-
]
74+
],
75+
self::MIME_TYPES
7676
);
7777
$fieldType->setTransformationProcessor($this->getTransformationProcessorMock());
7878

0 commit comments

Comments
 (0)