Skip to content

Commit

Permalink
Rename insert to prependFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkla committed Nov 2, 2023
1 parent f9e6cca commit 6ce35c6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ Gallery::make('Images')
->library('all') // all, uploadedTo
->returnFormat('array') // id, url, array (default)
->previewSize('medium') // thumbnail, medium, large
->prependFiles()
->required()
```

Expand Down Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions src/Fields/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}
Expand Down
10 changes: 2 additions & 8 deletions tests/Fields/GalleryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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();
}
}

0 comments on commit 6ce35c6

Please sign in to comment.