sohoa/framework — pull request #50 by camael24 (2014-01-10 10:23:09+00:00)
Title: Enable nested rules

```PHP
router;

$router->addResourceRule('b' , 'head' , '/');
$router->resource('foo')->resource('bar')->resource('qux');

echo Text::columnize($router->dump()); // Text est pas dans sohoa

}
```
Va générer :
```
C:\wamp\www\framework>php r.php
indexFoo get /foo/ Foo#index
newFoo get /foo/new Foo#new
showFoo get /foo/(?[a-z0-9]+[^/]?) Foo#show
createFoo post /foo/ Foo#create
editFoo get /foo/(?[a-z0-9]+[^/]*)/edit Foo#edit
updateFoo patch /foo/(?[a-z0-9]+[^/]?) Foo#update
destroyFoo delete /foo/(?[a-z0-9]+[^/]?) Foo#destroy
bFoo head /foo/ Foo#b
indexBar get /foo/(?[a-z0-9]+[^/]?)/bar/ Bar#index
newBar get /foo/(?[a-z0-9]+[^/]?)/bar/new Bar#new
showBar get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?) Bar#show
createBar post /foo/(?[a-z0-9]+[^/]?)/bar/ Bar#create
editBar get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]*)/edit Bar#edit
updateBar patch /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?) Bar#update
destroyBar delete /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?) Bar#destroy
bBar head /foo/(?[a-z0-9]+[^/]?)/bar/ Bar#b
indexQux get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?)/qux/ Qux#index
newQux get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?)/qux/new Qux#new
showQux get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?)/qux/(?[a-z0-9]+[^/]?) Qux#show
createQux post /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?)/qux/ Qux#create
editQux get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?)/qux/(?[a-z0-9]+[^/]*)/edit Qux#edit
updateQux patch /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?)/qux/(?[a-z0-9]+[^/]?) Qux#update
destroyQux delete /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?)/qux/(?[a-z0-9]+[^/]?) Qux#destroy
bQux head /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?)/qux/ Qux#b

```
Alors que
```
$router->resource('foo')->resource('bar')->resource('qux' , array('variable' => 'id', 'only' => array('show')))
```
```
indexFoo get /foo/ Foo#index
newFoo get /foo/new Foo#new
showFoo get /foo/(?[a-z0-9]+[^/]?) Foo#show
createFoo post /foo/ Foo#create
editFoo get /foo/(?[a-z0-9]+[^/]*)/edit Foo#edit
updateFoo patch /foo/(?[a-z0-9]+[^/]?) Foo#update
destroyFoo delete /foo/(?[a-z0-9]+[^/]?) Foo#destroy
bFoo head /foo/ Foo#b
indexBar get /foo/(?[a-z0-9]+[^/]?)/bar/ Bar#index
newBar get /foo/(?[a-z0-9]+[^/]?)/bar/new Bar#new
showBar get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?) Bar#show
createBar post /foo/(?[a-z0-9]+[^/]?)/bar/ Bar#create
editBar get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]*)/edit Bar#edit
updateBar patch /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?) Bar#update
destroyBar delete /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?) Bar#destroy
bBar head /foo/(?[a-z0-9]+[^/]?)/bar/ Bar#b
showQux get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?)/qux/(?[a-z0-9]+[^/]?) Qux#show
```

Et si on fait
```
$router->resource('foo')->resource('bar' , array('only' => array('show')))->resource('qux' , array('variable' => 'id', 'only' => array('show')));
```

Alors on a bien

```
indexFoo get /foo/ Foo#index
newFoo get /foo/new Foo#new
showFoo get /foo/(?[a-z0-9]+[^/]?) Foo#show
createFoo post /foo/ Foo#create
editFoo get /foo/(?[a-z0-9]+[^/]*)/edit Foo#edit
updateFoo patch /foo/(?[a-z0-9]+[^/]?) Foo#update
destroyFoo delete /foo/(?[a-z0-9]+[^/]?) Foo#destroy
bFoo head /foo/ Foo#b
showBar get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?) Bar#show
showQux get /foo/(?[a-z0-9]+[^/]?)/bar/(?[a-z0-9]+[^/]?)/qux/(?[a-z0-9]+[^/]?) Qux#show
```

La seule chose a savoir pour les règles nested (ou imbriquées) est d'avoir dans son parent la regle show sinon on obtient l'erreur `PHP Fatal error: Uncaught Hoa\Router\Generic::getRule(): (2) Rule showBar does not exist.`