Skip to content

Commit

Permalink
Propagated request $data into request->schema() method
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaplet committed May 2, 2024
1 parent f8a58dd commit c0d4324
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Http/Request/Admin/ProfileRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(protected readonly EntityManager $em, protected read
{
}

public function schema(): array
public function schema(array $data): array
{
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Admin/UploadAvatarRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(protected readonly AuthUser $user, protected readonl
{
}

public function schema(): array
public function schema(array $data): array
{
return ['avatar' => Expect::type(UploadedFile::class)->required()];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Auth/EmailAuthRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function __construct(
{
}

public function schema(): array
public function schema(array $data): array
{
$all = $this->entityFinder->findAll();
$filtered = array_filter($all, fn($item) => is_subclass_of($item['className'], IAuthenticable::class));
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Auth/RevokeTokenRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
{
}

public function schema(): array
public function schema(array $data): array
{
$all = $this->entityFinder->findAll();
$filtered = array_filter($all, fn($item) => is_subclass_of($item['className'], IAuthenticable::class));
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Collection/CreateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
{
}

public function schema(): array
public function schema(array $data): array
{
$recipeKeys = array_map(fn($r) => $r->key(), $this->recipeFinder->load()->getAll());

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Collection/DeleteRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(
{
}

public function schema(): array
public function schema(array $data): array
{
$recipeKeys = array_map(fn($r) => $r->key(), $this->recipeFinder->load()->getAll());

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Collection/Form/CreatingFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
{
}

public function schema(): array
public function schema(array $data): array
{
$recipeKeys = array_map(fn($r) => $r->key(), $this->recipeFinder->load()->getAll());

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Collection/Form/UpdatingFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
{
}

public function schema(): array
public function schema(array $data): array
{
$recipeKeys = array_map(fn($r) => $r->key(), $this->recipeFinder->load()->getAll());

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Collection/NavbarRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(
{
}

public function schema(): array
public function schema(array $data): array
{
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Collection/ReadRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(
{
}

public function schema(): array
public function schema(array $data): array
{
$recipeKeys = array_map(fn($r) => $r->key(), $this->recipeFinder->load()->getAll());

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Collection/UpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
{
}

public function schema(): array
public function schema(array $data): array
{
$recipeKeys = array_map(fn($r) => $r->key(), $this->recipeFinder->load()->getAll());

Expand Down
3 changes: 2 additions & 1 deletion src/Http/Request/IRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
interface IRequest
{
/**
* @param array<string|int, mixed> $data
* @return array<string|int, mixed>
*/
public function schema(): array;
public function schema(array $data): array;

/**
* @param array<string|int, mixed> $data
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __invoke(SymfonyRequest $request): Response
$this->request = $request;

$data = $this->getRequestData();
$schema = $this->schema();
$schema = $this->schema($data);

if (count($schema) !== 0) {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Resource/CreateRoleRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(protected EntityManager $em)
{
}

public function schema(): array
public function schema(array $data): array
{
return [
'name' => Expect::string()->min(3)->max(32)->required(),
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Resource/DeleteRoleRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct(protected EntityManager $em)
{
}

public function schema(): array
public function schema(array $data): array
{
return [
'id' => Expect::string()->required(),
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Resource/ReadAllRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(
{
}

public function schema(): array
public function schema(array $data): array
{
return [
'view_resources' => Expect::arrayOf('string')->required(),
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Request/Resource/UpdateRoleRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __construct(protected EntityManager $em)
{
}

public function schema(): array
public function schema(array $data): array
{
return [
'resource_id' => Expect::string()->required(),
Expand Down

0 comments on commit c0d4324

Please sign in to comment.