Skip to content

Commit

Permalink
added BootableProviderInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Apr 29, 2014
1 parent 1ba15a1 commit df568cb
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 72 deletions.
31 changes: 31 additions & 0 deletions src/Silex/Api/BootableProviderInterface.php
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Silex\Api;

use Silex\Application;

/**
* Interface that must implement all Silex service providers.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface BootableProviderInterface
{
/**
* Bootstraps the application.
*
* This method is called after all services are registered
* and should be used for "dynamic" configuration (whenever
* a service must be requested).
*/
public function boot(Application $app);
}
9 changes: 0 additions & 9 deletions src/Silex/Api/ServiceProviderInterface.php
Expand Up @@ -29,13 +29,4 @@ interface ServiceProviderInterface
* @param Application $app An Application instance
*/
public function register(Application $app);

/**
* Bootstraps the application.
*
* This method is called after all services are registered
* and should be used for "dynamic" configuration (whenever
* a service must be requested).
*/
public function boot(Application $app);
}
5 changes: 4 additions & 1 deletion src/Silex/Application.php
Expand Up @@ -30,6 +30,7 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RequestContext;
use Silex\Api\BootableProviderInterface;
use Silex\Api\EventListenerProviderInterface;
use Silex\Api\ControllerProviderInterface;
use Silex\Api\ServiceProviderInterface;
Expand Down Expand Up @@ -189,7 +190,9 @@ public function boot()
$provider->subscribe($this, $this['dispatcher']);
}

$provider->boot($this);
if ($provider instanceof BootableProviderInterface) {
$provider->boot($this);
}
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/Silex/Provider/DoctrineServiceProvider.php
Expand Up @@ -127,8 +127,4 @@ public function register(Application $app)
return $dbs[$app['dbs.default']];
});
}

public function boot(Application $app)
{
}
}
4 changes: 0 additions & 4 deletions src/Silex/Provider/FormServiceProvider.php
Expand Up @@ -103,8 +103,4 @@ public function register(Application $app)
return new DefaultCsrfProvider($app['form.secret']);
});
}

public function boot(Application $app)
{
}
}
4 changes: 0 additions & 4 deletions src/Silex/Provider/HttpCacheServiceProvider.php
Expand Up @@ -58,8 +58,4 @@ public function subscribe(Application $app, EventDispatcherInterface $dispatcher
{
$dispatcher->addSubscriber($app['http_cache.esi_listener']);
}

public function boot(Application $app)
{
}
}
4 changes: 0 additions & 4 deletions src/Silex/Provider/HttpFragmentServiceProvider.php
Expand Up @@ -82,8 +82,4 @@ public function subscribe(Application $app, EventDispatcherInterface $dispatcher
{
$dispatcher->addSubscriber($app['fragment.listener']);
}

public function boot(Application $app)
{
}
}
3 changes: 2 additions & 1 deletion src/Silex/Provider/MonologServiceProvider.php
Expand Up @@ -15,6 +15,7 @@
use Monolog\Handler\StreamHandler;
use Silex\Application;
use Silex\Api\ServiceProviderInterface;
use Silex\Api\BootableProviderInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -26,7 +27,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class MonologServiceProvider implements ServiceProviderInterface
class MonologServiceProvider implements ServiceProviderInterface, BootableProviderInterface
{
public function register(Application $app)
{
Expand Down
4 changes: 0 additions & 4 deletions src/Silex/Provider/RememberMeServiceProvider.php
Expand Up @@ -103,8 +103,4 @@ public function subscribe(Application $app, EventDispatcherInterface $dispatcher
{
$dispatcher->addSubscriber($app['security.remember_me.response_listener']);
}

public function boot(Application $app)
{
}
}
3 changes: 2 additions & 1 deletion src/Silex/Provider/SecurityServiceProvider.php
Expand Up @@ -12,6 +12,7 @@
namespace Silex\Provider;

use Silex\Application;
use Silex\Api\BootableProviderInterface;
use Silex\Api\ControllerProviderInterface;
use Silex\Api\ServiceProviderInterface;
use Silex\Api\EventListenerProviderInterface;
Expand Down Expand Up @@ -60,7 +61,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SecurityServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface, ControllerProviderInterface
class SecurityServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface, ControllerProviderInterface, BootableProviderInterface
{
protected $fakeRoutes;

Expand Down
11 changes: 0 additions & 11 deletions src/Silex/Provider/SerializerServiceProvider.php
Expand Up @@ -49,15 +49,4 @@ public function register(Application $app)
return array(new CustomNormalizer(), new GetSetMethodNormalizer());
});
}

/**
* {@inheritDoc}
*
* This provider does not execute any code when booting.
*
* @param Silex\Application $app
*/
public function boot(Application $app)
{
}
}
5 changes: 0 additions & 5 deletions src/Silex/Provider/ServiceControllerServiceProvider.php
Expand Up @@ -23,9 +23,4 @@ public function register(Application $app)
return new ServiceControllerResolver($resolver, $app['callback_resolver']);
}));
}

public function boot(Application $app)
{
// noop
}
}
4 changes: 0 additions & 4 deletions src/Silex/Provider/SessionServiceProvider.php
Expand Up @@ -85,8 +85,4 @@ public function subscribe(Application $app, EventDispatcherInterface $dispatcher
$app['dispatcher']->addSubscriber($app['session.listener.test']);
}
}

public function boot(Application $app)
{
}
}
4 changes: 0 additions & 4 deletions src/Silex/Provider/SwiftmailerServiceProvider.php
Expand Up @@ -98,8 +98,4 @@ public function subscribe(Application $app, EventDispatcherInterface $dispatcher
}
});
}

public function boot(Application $app)
{
}
}
4 changes: 0 additions & 4 deletions src/Silex/Provider/TranslationServiceProvider.php
Expand Up @@ -53,8 +53,4 @@ public function register(Application $app)
$app['translator.domains'] = array();
$app['locale_fallbacks'] = array('en');
}

public function boot(Application $app)
{
}
}
4 changes: 0 additions & 4 deletions src/Silex/Provider/TwigServiceProvider.php
Expand Up @@ -106,8 +106,4 @@ public function register(Application $app)
));
});
}

public function boot(Application $app)
{
}
}
4 changes: 0 additions & 4 deletions src/Silex/Provider/UrlGeneratorServiceProvider.php
Expand Up @@ -30,8 +30,4 @@ public function register(Application $app)
return new UrlGenerator($app['routes'], $app['request_context']);
});
}

public function boot(Application $app)
{
}
}
4 changes: 0 additions & 4 deletions src/Silex/Provider/ValidatorServiceProvider.php
Expand Up @@ -58,8 +58,4 @@ public function register(Application $app)
return array();
});
}

public function boot(Application $app)
{
}
}

0 comments on commit df568cb

Please sign in to comment.