Skip to content

Commit 1b87dec

Browse files
committed
WIP corrected ParameterResolver
1 parent aa3402b commit 1b87dec

File tree

7 files changed

+13
-29
lines changed

7 files changed

+13
-29
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## [1.0.0-RC5] - 2025-09-
8+
9+
710
## [1.0.0-RC4] - 2025-09-19
811
- Documentation tweaks
912
- AbstractActionHandler implements ParameterizableInterface

src/Exceptions/MissingUriKeyException.php

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Services/ParameterResolver.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use LaravelUi5\Core\Exceptions\InvalidParameterValueException;
2020
use LaravelUi5\Core\Exceptions\InvalidPathException;
2121
use LaravelUi5\Core\Exceptions\MissingRequiredParameterException;
22-
use LaravelUi5\Core\Exceptions\MissingUriKeyException;
2322
use LaravelUi5\Core\Exceptions\NoModelFoundForParameterException;
2423
use LaravelUi5\Core\Ui5\Contracts\ParameterizableInterface;
2524
use ReflectionClass;
@@ -40,6 +39,7 @@ public function resolve(ParameterizableInterface $target): Ui5Args
4039
$attributes = $reflection->getAttributes(Parameter::class);
4140
$uriKeys = $this->getUriKeys();
4241
$out = [];
42+
$index = 0;
4343

4444
/** @var Parameter $attribute */
4545
foreach ($attributes as $a) {
@@ -50,10 +50,7 @@ public function resolve(ParameterizableInterface $target): Ui5Args
5050
// 1. Get the raw value
5151
switch ($attribute->source) {
5252
case ParameterSource::Path:
53-
if (null === $attribute->uriKey) {
54-
throw new MissingUriKeyException($name);
55-
}
56-
$raw = $uriKeys[$attribute->uriKeyPosition] ?? null;
53+
$raw = $uriKeys[$index] ?? null;
5754
break;
5855
case ParameterSource::Query:
5956
$raw = $this->request->query($name);

src/Ui5/AbstractActionHandler.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44

55
use LaravelUi5\Core\Contracts\Ui5Args;
66
use LaravelUi5\Core\Ui5\Contracts\ActionHandlerInterface;
7-
use LaravelUi5\Core\Ui5\Contracts\ParameterizableInterface;
87

9-
abstract class AbstractActionHandler implements ActionHandlerInterface, ParameterizableInterface
8+
abstract class AbstractActionHandler implements ActionHandlerInterface
109
{
1110
protected Ui5Args $args;
1211

src/Ui5/AbstractLaravelUi5Manifest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use LaravelUi5\Core\Exceptions\InvalidParameterSourceException;
99
use LaravelUi5\Core\Ui5\Contracts\LaravelUi5ManifestInterface;
1010
use LaravelUi5\Core\Ui5\Contracts\LaravelUi5ManifestKeys;
11-
use LaravelUi5\Core\Ui5\Contracts\Ui5ActionInterface;
11+
use LaravelUi5\Core\Ui5\Contracts\ParameterizableInterface;
1212
use LaravelUi5\Core\Ui5\Contracts\Ui5RegistryInterface;
1313
use ReflectionClass;
1414
use RuntimeException;
@@ -87,7 +87,7 @@ protected function buildActions(string $module): array
8787
throw new InvalidHttpMethodActionException($action->getNamespace(), $action->getMethod()->label());
8888
}
8989

90-
$uri = collect($this->getPathParameters($action))
90+
$uri = collect($this->getPathParameters($action->getHandler()))
9191
->map(fn(string $parameter) => "/{{$parameter}}")
9292
->implode('');
9393

@@ -100,9 +100,9 @@ protected function buildActions(string $module): array
100100
return $actions;
101101
}
102102

103-
protected function getPathParameters(Ui5ActionInterface $action): array
103+
protected function getPathParameters(ParameterizableInterface $target): array
104104
{
105-
$reflection = new ReflectionClass($action);
105+
$reflection = new ReflectionClass($target);
106106
$attributes = $reflection->getAttributes(Parameter::class);
107107
$parameters = [];
108108
foreach ($attributes as $attr) {

src/Ui5/Contracts/ActionHandlerInterface.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@
2323
* feature flags that influence runtime behavior.
2424
*
2525
* Notes:
26-
* - URI parameters are resolved at the Action level (via
27-
* {@see Ui5ActionInterface} + {@see ParameterizableInterface}),
28-
* not on the handler itself.
26+
* - Input expectations are declared via {@see ParameterizableInterface},
2927
* - ActionHandlers must always return a structured result, even if
3028
* no payload is strictly required (e.g., a simple status + message).
3129
* - Dependencies (repositories, services) should be injected via
3230
* constructor dependency injection for testability and clarity.
3331
*/
34-
interface ActionHandlerInterface extends ExecutableInterface
32+
interface ActionHandlerInterface extends ExecutableInterface, ParameterizableInterface
3533
{
3634
}

src/Ui5/Contracts/Ui5ActionInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,14 @@
1616
* Characteristics:
1717
* - Actions are always *mutating* operations (never pure reads).
1818
* - Therefore, they must only be exposed as *POST endpoints*.
19-
* - Route parameters (IDs, slugs) are declared on the Action and resolved
19+
* - Route parameters (IDs, slugs) are declared on the ActionHandler and resolved
2020
* via {@see ParameterizableInterface}. The dispatcher validates and
2121
* injects these before calling the handler.
2222
* - Body parameters (form data, payloads) are validated *inside the
2323
* ActionHandler*, following Laravel best practices.
2424
*
2525
* Responsibilities:
2626
* - Define the action’s slug (via {@see SluggableInterface}).
27-
* - Optionally implement {@see ParameterizableInterface} to declare
28-
* URI parameters.
2927
* - Provide the {@see ActionHandlerInterface} that executes the logic.
3028
*
3129
* Each Action must have a unique slug within its module. The slug is used

0 commit comments

Comments
 (0)