You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -247,6 +250,25 @@ $route->call(function ($class) use ($container) {
247
250
```
248
251
249
252
253
+
### Names
254
+
255
+
All the routes allow you to apply names to then, this names can be used to find a route in the `Collector` or to generate links with `Path`'s method `to(string name, array args = [])`. E.g.
256
+
257
+
```php
258
+
// ...
259
+
// The Path class will create several links for us, just give they new object a instance of the collector.
// this will print an anchor tag with "/blog/my-first-article" in href.
266
+
echo "<ahref='", $path->to("blog.article", ["article" => "my-first-article"]), "'>My First Article</a>";
267
+
```
268
+
269
+
> **NOTE:** For best practice use the dot for delimiting namespaces in your route names, so you can group and find they names easily. The [resource](#resources-route-names) collector adopt this concept.
270
+
271
+
250
272
### Metadata
251
273
252
274
Sometimes you want to delegate more information to a route, for post match filters or action execution strategies. For persist data that will not be passed to action but used in somewhere before the execution use the `setMetadata(string key, mixed value)` method.
If you prefer to translate the patterns generated by the resource, just define an `translate` option that receives an array with one or the two keys, `new` and `edit`.
0 commit comments