Skip to content

Commit

Permalink
Allows the field generation to take advantage of the current request …
Browse files Browse the repository at this point in the history
…to allow for things like tenant identification
  • Loading branch information
craigpaul committed Sep 12, 2024
1 parent a9c488b commit bb63cc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/Http/Controllers/WorkflowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use SplFileInfo;

class WorkflowController
Expand All @@ -30,9 +31,11 @@ public function __construct(
/**
* Display a listing of the resource.
*
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\JsonResponse
*/
public function index(): JsonResponse
public function index(Request $request): JsonResponse
{
$directory = $this->app->basePath('tests/Blitz');

Expand All @@ -46,11 +49,11 @@ public function index(): JsonResponse
),
);

$workflows = array_map(function (SplFileInfo $file) {
$workflows = array_map(function (SplFileInfo $file) use ($request) {
$workflow = Workflow::fromFile($file);
$namespace = $workflow->className;
$fields = $workflow->customizable
? $this->app->make($namespace)->fields()
? $this->app->make($namespace)->fields($request)
: [];

return [
Expand Down
2 changes: 1 addition & 1 deletion src/Support/Workflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ className: str_replace(
),
),
),
customizable: self::fileContains($file, 'public function fields()'),
customizable: self::fileContains($file, 'public function fields'),
name: ucfirst(
strtolower(
implode(' ', preg_split('/(?=\p{Lu})/u', strstr($file->getFilename(), 'Test.php', true), -1, PREG_SPLIT_NO_EMPTY)),
Expand Down

0 comments on commit bb63cc8

Please sign in to comment.