Skip to content

Commit

Permalink
Rename mimeTypes to acceptableFileTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkla committed Oct 19, 2023
1 parent db6eff3 commit b4d8526
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 22 deletions.
33 changes: 23 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,8 @@ TrueFalse::make('Social Media', 'display_social_media')
use Extended\ACF\Fields\File;

File::make('Resturant Menu', 'menu')
->instructions('Add the menu <strong>pdf</strong> file.')
->instructions('Add the menu **pdf** file.')
->mimeTypes(['pdf'])
->acceptedFileTypes(['pdf'])
->library('all') // all, uploadedTo
->minSize('400 KB')
->maxSize(5) // MB if entered as int
Expand All @@ -270,7 +269,7 @@ use Extended\ACF\Fields\Gallery;

Gallery::make('Images')
->instructions('Add the gallery images.')
->mimeTypes(['jpg', 'jpeg', 'png'])
->acceptedFileTypes(['jpg', 'jpeg', 'png'])
->minHeight(500)
->maxHeight(1400)
->minWidth(1000)
Expand All @@ -292,7 +291,7 @@ use Extended\ACF\Fields\Image;

Image::make('Background Image')
->instructions('Add an image in at least 12000x100px and only in the formats **jpg**, **jpeg** or **png**.')
->mimeTypes(['jpg', 'jpeg', 'png'])
->acceptedFileTypes(['jpg', 'jpeg', 'png'])
->minHeight(500)
->maxHeight(1400)
->minWidth(1000)
Expand Down Expand Up @@ -881,32 +880,46 @@ The upgrade guide provides information about the breaking changes in the package
10\. The `width` method has been split into two methods `minWidth` and `maxWidth`.

```diff
-Gallery::make('Background')->width(100, 1000)
+Gallery::make('Background')->minWidth(100)->maxWidth(1000)
-Image::make('Background')->width(100, 1000)
+Image::make('Background')->minWidth(100)->maxWidth(1000)
```

11\. The `CharacterLimit` trait has been renamed to `MaxLength`.
11\. The `mimeTypes` method has been renamed to `acceptedFileTypes`.

```diff
-File::make('Background')->mimeTypes(['pdf'])
+File::make('Background')->acceptedFileTypes(['pdf'])
```

12\. The `MimeTypes` trait has been renamed to `FileTypes`.

```diff
-use Extended\ACF\Fields\Settings\MimeTypes;
+use Extended\ACF\Fields\Settings\FileTypes;
```

13\. The `CharacterLimit` trait has been renamed to `MaxLength`.

```diff
-use Extended\ACF\Fields\Settings\CharacterLimit;
+use Extended\ACF\Fields\Settings\MaxLength;
```

12\. The `Pending` trait has been renamed to `Affixable`.
14\. The `Pending` trait has been renamed to `Affixable`.

```diff
-use Extended\ACF\Fields\Settings\Pending;
+use Extended\ACF\Fields\Settings\Affixable;
```

13\. The `Writable` trait has been renamed to `Immutable`.
15\. The `Writable` trait has been renamed to `Immutable`.

```diff
-use Extended\ACF\Fields\Settings\Writable;
+use Extended\ACF\Fields\Settings\Immutable;
```

14\. The `SubFields` trait has been renamed to `Fields`.
16\. The `SubFields` trait has been renamed to `Fields`.

```diff
-use Extended\ACF\Fields\Settings\SubFields;
Expand Down
4 changes: 2 additions & 2 deletions src/Fields/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

use Extended\ACF\Fields\Settings\ConditionalLogic;
use Extended\ACF\Fields\Settings\FileSize;
use Extended\ACF\Fields\Settings\FileTypes;
use Extended\ACF\Fields\Settings\Instructions;
use Extended\ACF\Fields\Settings\Library;
use Extended\ACF\Fields\Settings\MimeTypes;
use Extended\ACF\Fields\Settings\Required;
use Extended\ACF\Fields\Settings\ReturnFormat;
use Extended\ACF\Fields\Settings\Wrapper;
Expand All @@ -28,7 +28,7 @@ class File extends Field
use FileSize;
use Instructions;
use Library;
use MimeTypes;
use FileTypes;
use Required;
use ReturnFormat;
use Wrapper;
Expand Down
4 changes: 2 additions & 2 deletions src/Fields/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use Extended\ACF\Fields\Settings\ConditionalLogic;
use Extended\ACF\Fields\Settings\Dimensions;
use Extended\ACF\Fields\Settings\FileSize;
use Extended\ACF\Fields\Settings\FileTypes;
use Extended\ACF\Fields\Settings\Instructions;
use Extended\ACF\Fields\Settings\Library;
use Extended\ACF\Fields\Settings\MimeTypes;
use Extended\ACF\Fields\Settings\MinMax;
use Extended\ACF\Fields\Settings\PreviewSize;
use Extended\ACF\Fields\Settings\Required;
Expand All @@ -33,7 +33,7 @@ class Gallery extends Field
use FileSize;
use Instructions;
use Library;
use MimeTypes;
use FileTypes;
use MinMax;
use PreviewSize;
use Required;
Expand Down
4 changes: 2 additions & 2 deletions src/Fields/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
use Extended\ACF\Fields\Settings\ConditionalLogic;
use Extended\ACF\Fields\Settings\Dimensions;
use Extended\ACF\Fields\Settings\FileSize;
use Extended\ACF\Fields\Settings\FileTypes;
use Extended\ACF\Fields\Settings\Instructions;
use Extended\ACF\Fields\Settings\Library;
use Extended\ACF\Fields\Settings\MimeTypes;
use Extended\ACF\Fields\Settings\PreviewSize;
use Extended\ACF\Fields\Settings\Required;
use Extended\ACF\Fields\Settings\ReturnFormat;
Expand All @@ -31,7 +31,7 @@ class Image extends Field
use FileSize;
use Instructions;
use Library;
use MimeTypes;
use FileTypes;
use PreviewSize;
use Required;
use ReturnFormat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@

namespace Extended\ACF\Fields\Settings;

trait MimeTypes
trait FileTypes
{
public function mimeTypes(array $mimeTypes): static
public function acceptedFileTypes(array|string $types): static
{
$this->settings['mime_types'] = implode(',', $mimeTypes);
if (is_string($types)) {
$types = [$types];
}

$this->settings['mime_types'] = implode(',', $types);

return $this;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Fields/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public function testType()
$this->assertSame('file', $field['type']);
}

public function testMimeTypes()
public function testAcceptedFileTypes()
{
$field = File::make('Mime Types')->mimeTypes(['jpg', 'pdf'])->get();
$this->assertSame('jpg,pdf', $field['mime_types']);
$field = File::make('File Accepted File Types')->acceptedFileTypes(['image/jpg', 'application/pdf'])->get();
$this->assertSame('image/jpg,application/pdf', $field['mime_types']);
}

public function testReturnFormat()
Expand Down

0 comments on commit b4d8526

Please sign in to comment.