Skip to content

Commit

Permalink
Revert to invokable
Browse files Browse the repository at this point in the history
  • Loading branch information
szepeviktor committed Jun 17, 2024
1 parent 2316b09 commit 92e8cf1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/app/Library/CrudPanel/Traits/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,12 +505,12 @@ public function getStrippedSaveRequest($request)
return $setting($request);
}

// if an invocable class was passed
// if an invokable class was passed
// eg. \App\Http\Requests\BackpackStrippedRequest
if (is_string($setting) && class_exists($setting)) {
$setting = new $setting();

return is_callable($setting) ? $setting($request) : abort(500, get_class($setting).' is not invocable.');
return is_callable($setting) ? $setting($request) : abort(500, get_class($setting).' is not invokable.');
}

return $request->only($this->getAllFieldNames());
Expand Down
2 changes: 1 addition & 1 deletion src/config/backpack/operations/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@

// Before saving the entry, how would you like the request to be stripped?
// - false - use Backpack's default (ONLY save inputs that have fields)
// - invocable class - custom stripping (the return should be an array with input names)
// - invokable class - custom stripping (the return should be an array with input names)
// 'strippedRequest' => App\Http\Requests\StripBackpackRequest::class,
];
2 changes: 1 addition & 1 deletion src/config/backpack/operations/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@

// Before saving the entry, how would you like the request to be stripped?
// - false - use Backpack's default (ONLY save inputs that have fields)
// - invocable class - custom stripping (the return should be an array with input names)
// - invokable class - custom stripping (the return should be an array with input names)
// 'strippedRequest' => App\Http\Requests\StripBackpackRequest::class,
];
2 changes: 1 addition & 1 deletion src/config/backpack/operations/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@

// Before saving the entry, how would you like the request to be stripped?
// - false - use Backpack's default (ONLY save inputs that have fields)
// - invocable class - custom stripping (the return should be an array with input names)
// - invokable class - custom stripping (the return should be an array with input names)
// 'strippedRequest' => App\Http\Requests\StripBackpackRequest::class,
];
8 changes: 4 additions & 4 deletions tests/Unit/CrudPanel/CrudPanelFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -626,15 +626,15 @@ public function testGetStrippedSaveRequestWithClass()
{
$this->crudPanel->setOperationSetting(
'strippedRequest',
Invocable::class,
Invokable::class,
'update'
);
$this->crudPanel->setOperation('update');
$this->crudPanel->setModel(User::class);
$request = request()->create('/users/1/edit', 'POST', ['name' => 'john']);
$result = $this->crudPanel->getStrippedSaveRequest($request);
$this->assertIsArray($result);
$this->assertSame(['invocable' => 'invocable'], $result);
$this->assertSame(['invokable' => 'invokable'], $result);
}

public function testItDoesNotUseProtectedMethodsAsRelationshipMethods()
Expand Down Expand Up @@ -900,10 +900,10 @@ public function testCheckReturnTypesForWhenInferringRelation()
}
}

class Invocable
class Invokable
{
public function __invoke(): array
{
return ['invocable' => 'invocable'];
return ['invokable' => 'invokable'];
}
}

0 comments on commit 92e8cf1

Please sign in to comment.