From 6ce35c6a82c92d655f8cda265e4314bc8b3f9375 Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Thu, 2 Nov 2023 07:48:07 +0100 Subject: [PATCH] Rename `insert` to `prependFiles` --- README.md | 8 ++++++++ src/Fields/Gallery.php | 13 ++----------- tests/Fields/GalleryTest.php | 10 ++-------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 95e58020..28804518 100644 --- a/README.md +++ b/README.md @@ -281,6 +281,7 @@ Gallery::make('Images') ->library('all') // all, uploadedTo ->returnFormat('array') // id, url, array (default) ->previewSize('medium') // thumbnail, medium, large + ->prependFiles() ->required() ``` @@ -934,6 +935,13 @@ The `width` method has been split into two methods `minWidth` and `maxWidth`. +Image::make('Product Image')->minWidth(100)->maxWidth(1000) ``` +The `insert` method has been renamed to `prependFiles`. + +```diff +-Gallery::make('Downloads')->insert('prepend') ++Gallery::make('Downloads')->prependFiles() +``` + The `mimeTypes` method has been renamed to `acceptedFileTypes`. ```diff diff --git a/src/Fields/Gallery.php b/src/Fields/Gallery.php index f3f5ef65..2f5a1ce8 100644 --- a/src/Fields/Gallery.php +++ b/src/Fields/Gallery.php @@ -24,7 +24,6 @@ use Extended\ACF\Fields\Settings\Required; use Extended\ACF\Fields\Settings\ReturnFormat; use Extended\ACF\Fields\Settings\Wrapper; -use InvalidArgumentException; class Gallery extends Field { @@ -42,17 +41,9 @@ class Gallery extends Field protected string|null $type = 'gallery'; - /** - * @param string $insert append, prepend - * @throws \InvalidArgumentException - */ - public function insert(string $insert): static + public function prependFiles(): static { - if (!in_array($insert, ['append', 'prepend'])) { - throw new InvalidArgumentException("Invalid argument insert [$insert]"); - } - - $this->settings['insert'] = $insert; + $this->settings['insert'] = 'prepend'; return $this; } diff --git a/tests/Fields/GalleryTest.php b/tests/Fields/GalleryTest.php index a20f679c..d3c0ab1d 100644 --- a/tests/Fields/GalleryTest.php +++ b/tests/Fields/GalleryTest.php @@ -25,7 +25,6 @@ use Extended\ACF\Tests\Fields\Settings\Required; use Extended\ACF\Tests\Fields\Settings\ReturnFormat; use Extended\ACF\Tests\Fields\Settings\Wrapper; -use InvalidArgumentException; class GalleryTest extends FieldTestCase { @@ -44,14 +43,9 @@ class GalleryTest extends FieldTestCase public string $field = Gallery::class; public string $type = 'gallery'; - public function testInsert() + public function testPrependFiles() { - $field = Gallery::make('Insert')->insert('prepend')->get(); + $field = Gallery::make('Prepend Files')->prependFiles()->get(); $this->assertSame('prepend', $field['insert']); - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('Invalid argument insert [test]'); - - Gallery::make('Invalid Insert')->insert('test')->get(); } }