@@ -41,6 +41,16 @@ class ResourceRegistrar
41
41
*/
42
42
protected static $ singularParameters = true ;
43
43
44
+ /**
45
+ * Uri translations.
46
+ *
47
+ * @var array
48
+ */
49
+ protected static $ uriTranslations = [
50
+ 'create ' => 'create ' ,
51
+ 'edit ' => 'edit ' ,
52
+ ];
53
+
44
54
/**
45
55
* Create a new resource registrar instance.
46
56
*
@@ -290,7 +300,7 @@ protected function addResourceIndex($name, $base, $controller, $options)
290
300
*/
291
301
protected function addResourceCreate ($ name , $ base , $ controller , $ options )
292
302
{
293
- $ uri = $ this ->getResourceUri ($ name ).'/create ' ;
303
+ $ uri = $ this ->getResourceUri ($ name ).'/ ' . static :: $ uriTranslations [ ' create '] ;
294
304
295
305
$ action = $ this ->getResourceAction ($ name , $ controller , 'create ' , $ options );
296
306
@@ -344,7 +354,7 @@ protected function addResourceShow($name, $base, $controller, $options)
344
354
*/
345
355
protected function addResourceEdit ($ name , $ base , $ controller , $ options )
346
356
{
347
- $ uri = $ this ->getResourceUri ($ name ).'/{ ' .$ base .'}/edit ' ;
357
+ $ uri = $ this ->getResourceUri ($ name ).'/{ ' .$ base .'}/ ' . static :: $ uriTranslations [ ' edit '] ;
348
358
349
359
$ action = $ this ->getResourceAction ($ name , $ controller , 'edit ' , $ options );
350
360
@@ -418,4 +428,25 @@ public static function setParameters(array $parameters = [])
418
428
{
419
429
static ::$ parameterMap = $ parameters ;
420
430
}
431
+
432
+ /**
433
+ * Get the uri translations.
434
+ *
435
+ * @return array
436
+ */
437
+ public static function getUriTranslations ()
438
+ {
439
+ return static ::$ uriTranslations ;
440
+ }
441
+
442
+ /**
443
+ * Set the uri translations.
444
+ *
445
+ * @param array $translations
446
+ * @return void
447
+ */
448
+ public static function setUriTranslations (array $ translations = [])
449
+ {
450
+ static ::$ uriTranslations = array_merge (static ::$ uriTranslations , $ translations );
451
+ }
421
452
}
0 commit comments