Skip to content

Commit 0d180c2

Browse files
committed
wip
1 parent f4b6d60 commit 0d180c2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/1-essentials/01-routing.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@ final class Aircraft implements Bindable
103103
}
104104
```
105105

106+
By default, `Bindable` objects will be cast to strings when they are passed into the `uri()` function as a route parameter. You can override this default behaviour by tagging a public property on the object with the {b`\Tempest\Router\IsBindingValue`} attribute:
107+
108+
```php
109+
use Tempest\Router\Bindable;
110+
use Tempest\Router\IsBindingValue;
111+
112+
final class Aircraft implements Bindable
113+
{
114+
#[IsBindingValue]
115+
public string $callSign;
116+
117+
public function resolve(string $input): self
118+
{
119+
return self::find(id: $input);
120+
}
121+
}
122+
```
123+
106124
### Backed enum binding
107125

108126
You may inject string-backed enumerations to controller actions. Tempest will try to map the corresponding parameter from the URI to an instance of that enum using the [`tryFrom`](https://www.php.net/manual/en/backedenum.tryfrom.php) enum method.

0 commit comments

Comments
 (0)