-
-
Save nickl-/3104970 to your computer and use it in GitHub Desktop.
Another approach to multiple paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$paths = array( | |
'/users', | |
'/users/*', | |
'/users/*/lists', | |
'/users/*/lists/*', | |
); | |
// Multiple paths handled by single callback | |
$r3->any($paths, function ($userId=null,$listId=null) {/***/} | |
))->by($processors)->when($conditions)->through($formatters)->accept($conneg); | |
// Multiple paths handled by single controller | |
$r3->any($paths, 'MyApp\Controllers\UserController' | |
))->by($processors)->when($conditions)->through($formatters)->accept($conneg); | |
$paths = array( | |
'/users', | |
'/users/*', | |
'/users/*/lists', | |
'/users/*/lists/*', | |
'/user-roles', | |
'/user-roles/*', | |
'/user-roles/*/lists', | |
'/user-roles/*/lists/*', | |
'/user-perms', | |
'/user-perms/*', | |
'/user-perms/*/lists', | |
'/user-perms/*/lists/*', | |
); | |
// Multiple paths handled by single factory | |
// producing different controllers based on path | |
$r3->any($paths, "MyApp\Controllers\iControllerInterface", array('MyApp\Controllers\ControllerFactory', 'getControllerFor') | |
))->by($processors)->when($conditions)->through($formatters)->accept($conneg); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Possible implementation for linkTo: