Created
October 26, 2012 20:15
-
-
Save jmather/3961224 to your computer and use it in GitHub Desktop.
How to filter a set of urls by a constraint
This file contains hidden or 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 | |
| $app = new Silex\Application(); | |
| $app->mount('/admin', new MyCode\MyControllerProvider()); |
This file contains hidden or 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 | |
| namespace MyCode; | |
| use Silex\Application; | |
| use Silex\ControllerProviderInterface; | |
| use Silex\ControllerCollection; | |
| use Symfony\Component\HttpFoundation\Response; | |
| class MyControllerProvider implements ControllerProviderInterface | |
| { | |
| public function connect(Application $app) | |
| { | |
| // creates a new controller based on the default route | |
| /** @var $controllers ControllerCollection */ | |
| $controllers = $app['controllers_factory']; | |
| $controllers->get('/', function (Application $app) { | |
| return 'hello'; | |
| }): | |
| $controllers->before(function() { throw new \Exception(); }); | |
| return $controllers; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment