Commit eb5079be authored by Fabien Potencier's avatar Fabien Potencier

moved fake routes for the security service provider to a connect() method (with auto-registration)

parent 3fdfa4be
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Application; use Silex\Application;
use Silex\ControllerProviderInterface;
use Silex\ServiceProviderInterface; use Silex\ServiceProviderInterface;
use Silex\EventListenerProviderInterface; use Silex\EventListenerProviderInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
...@@ -59,7 +60,7 @@ use Symfony\Component\Security\Http\HttpUtils; ...@@ -59,7 +60,7 @@ use Symfony\Component\Security\Http\HttpUtils;
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
*/ */
class SecurityServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface class SecurityServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface, ControllerProviderInterface
{ {
protected $fakeRoutes; protected $fakeRoutes;
...@@ -542,13 +543,21 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -542,13 +543,21 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
$dispatcher->addSubscriber($app['security.firewall']); $dispatcher->addSubscriber($app['security.firewall']);
} }
public function boot(Application $app) public function connect(Application $app)
{ {
$controllers = $app['controllers_factory'];
foreach ($this->fakeRoutes as $route) { foreach ($this->fakeRoutes as $route) {
list($method, $pattern, $name) = $route; list($method, $pattern, $name) = $route;
$app->$method($pattern)->run(null)->bind($name); $controllers->$method($pattern)->run(null)->bind($name);
} }
return $controllers;
}
public function boot(Application $app)
{
$app->mount('/', $this->connect($app));
} }
public function addFakeRoute($method, $pattern, $name) public function addFakeRoute($method, $pattern, $name)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment