Commit 5a20c1cc authored by Fabien Potencier's avatar Fabien Potencier

renamed ExtensionInterface to ServiceProviderInterface and...

renamed ExtensionInterface to ServiceProviderInterface and ControllersExtensionInterface to ControllerProviderInterface
parent c006b758
This changelog references all backward incompatibilities as we introduce them:
* 2011-08-26: The way reusable applications work has changed. The `mount()`
* 2011-21-09: `ExtensionInterface` has been renamed to
`ServiceProviderInterface`.
* 2011-21-09: The way reusable applications work has changed. The `mount()`
method now takes an instance of `ControllerCollection` instead of an
`Application` one.
......
......@@ -102,18 +102,18 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
}
/**
* Registers an extension.
* Registers a service provider.
*
* @param ExtensionInterface $extension An ExtensionInterface instance
* @param array $values An array of values that customizes the extension
* @param ServiceProviderInterface $provider A ServiceProviderInterface instance
* @param array $values An array of values that customizes the provider
*/
public function register(ExtensionInterface $extension, array $values = array())
public function register(ServiceProviderInterface $provider, array $values = array())
{
foreach ($values as $key => $value) {
$this[$key] = $value;
}
$extension->register($this);
$provider->register($this);
}
/**
......@@ -298,17 +298,17 @@ class Application extends \Pimple implements HttpKernelInterface, EventSubscribe
/**
* Mounts an application under the given route prefix.
*
* @param string $prefix The route prefix
* @param ControllerCollection|ControllersExtensionInterface $app A ControllerCollection or an ControllersExtensionInterface instance
* @param string $prefix The route prefix
* @param ControllerCollection|ControllerProviderInterface $app A ControllerCollection or an ControllerProviderInterface instance
*/
public function mount($prefix, $app)
{
if ($app instanceof ControllersExtensionInterface) {
if ($app instanceof ControllerProviderInterface) {
$app = $app->connect($this);
}
if (!$app instanceof ControllerCollection) {
throw new \LogicException('The "mount" method takes either a ControllerCollection or a ControllersExtensionInterface instance.');
throw new \LogicException('The "mount" method takes either a ControllerCollection or a ControllerProviderInterface instance.');
}
$this['routes']->addCollection($app->flush(), $prefix);
......
......@@ -12,11 +12,11 @@
namespace Silex;
/**
* Interface for reusable controllers.
* Interface for controller providers.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface ControllersExtensionInterface
interface ControllerProviderInterface
{
/**
* Returns routes to connect to the given application.
......
......@@ -9,20 +9,20 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Configuration;
use Doctrine\Common\EventManager;
/**
* Doctrine DBAL extension.
* Doctrine DBAL Provider.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class DoctrineExtension implements ExtensionInterface
class DoctrineProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
......
......@@ -9,10 +9,10 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
use Symfony\Component\Form\FormFactory;
......@@ -21,11 +21,11 @@ use Symfony\Component\Form\Extension\Validator\ValidatorExtension as FormValidat
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
/**
* Symfony Form component extension.
* Symfony Form component Provider.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class FormExtension implements ExtensionInterface
class FormProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
......
......@@ -9,20 +9,20 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
use Silex\HttpCache;
use Symfony\Component\HttpKernel\HttpCache\Esi;
use Symfony\Component\HttpKernel\HttpCache\Store;
/**
* Symfony HttpKernel component extension for HTTP cache.
* Symfony HttpKernel component Provider for HTTP cache.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class HttpCacheExtension implements ExtensionInterface
class HttpCacheProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
......
......@@ -9,22 +9,22 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* Monolog extension.
* Monolog Provider.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class MonologExtension implements ExtensionInterface
class MonologProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
......
......@@ -9,21 +9,21 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
use Symfony\Component\HttpFoundation\SessionStorage\NativeSessionStorage;
use Symfony\Component\HttpFoundation\Session;
use Symfony\Component\HttpKernel\KernelEvents;
/**
* Symfony HttpFoundation component extension for sessions.
* Symfony HttpFoundation component Provider for sessions.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SessionExtension implements ExtensionInterface
class SessionProvider implements ServiceProviderInterface
{
private $app;
......
......@@ -9,17 +9,17 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
/**
* Swiftmailer extension.
* Swiftmailer Provider.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SwiftmailerExtension implements ExtensionInterface
class SwiftmailerProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
......
......@@ -9,17 +9,17 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
/**
* Symfony bridges extension.
* Symfony bridges Provider.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SymfonyBridgesExtension implements ExtensionInterface
class SymfonyBridgesProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
......
......@@ -9,21 +9,21 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Loader\ArrayLoader;
/**
* Symfony Translation component extension.
* Symfony Translation component Provider.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class TranslationExtension implements ExtensionInterface
class TranslationProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
......
......@@ -9,21 +9,21 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
use Symfony\Bridge\Twig\Extension\RoutingExtension as TwigRoutingExtension;
use Symfony\Bridge\Twig\Extension\TranslationExtension as TwigTranslationExtension;
use Symfony\Bridge\Twig\Extension\FormExtension as TwigFormExtension;
/**
* Twig extension.
* Twig Provider.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class TwigExtension implements ExtensionInterface
class TwigProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
......
......@@ -9,19 +9,19 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
use Symfony\Component\Routing\Generator\UrlGenerator;
/**
* Symfony Routing component extension for URL generation.
* Symfony Routing component Provider for URL generation.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class UrlGeneratorExtension implements ExtensionInterface
class UrlGeneratorProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
......
......@@ -9,10 +9,10 @@
* file that was distributed with this source code.
*/
namespace Silex\Extension;
namespace Silex\Provider;
use Silex\Application;
use Silex\ExtensionInterface;
use Silex\ServiceProviderInterface;
use Symfony\Component\Validator\Validator;
use Symfony\Component\Validator\Mapping\ClassMetadataFactory;
......@@ -20,11 +20,11 @@ use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader;
use Symfony\Component\Validator\ConstraintValidatorFactory;
/**
* Symfony Validator component extension.
* Symfony Validator component Provider.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class ValidatorExtension implements ExtensionInterface
class ValidatorProvider implements ServiceProviderInterface
{
public function register(Application $app)
{
......
......@@ -12,14 +12,14 @@
namespace Silex;
/**
* Interface that must implement all Silex extensions.
* Interface that must implement all Silex service providers.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface ExtensionInterface
interface ServiceProviderInterface
{
/**
* Registers an extension.
* Registers services on the given app.
*
* @param Application $app An Application instance
*/
......
......@@ -9,17 +9,17 @@
* with this source code in the file LICENSE.
*/
namespace Silex\Tests\Extension;
namespace Silex\Tests\Provider;
use Silex\Application;
use Silex\Extension\DoctrineExtension;
use Silex\Provider\DoctrineProvider;
/**
* DoctrineExtension test cases.
* DoctrineProvider test cases.
*
* Fabien Potencier <fabien@symfony.com>
*/
class DoctrineExtensionTest extends \PHPUnit_Framework_TestCase
class DoctrineProviderTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
......@@ -31,7 +31,7 @@ class DoctrineExtensionTest extends \PHPUnit_Framework_TestCase
public function testSingleConnection()
{
$app = new Application();
$app->register(new DoctrineExtension(), array(
$app->register(new DoctrineProvider(), array(
'db.common.class_path' => __DIR__.'/../../../../vendor/doctrine-common/lib',
'db.dbal.class_path' => __DIR__.'/../../../../vendor/doctrine-dbal/lib',
......@@ -51,7 +51,7 @@ class DoctrineExtensionTest extends \PHPUnit_Framework_TestCase
public function testMultipleConnections()
{
$app = new Application();
$app->register(new DoctrineExtension(), array(
$app->register(new DoctrineProvider(), array(
'db.common.class_path' => __DIR__.'/../../../../vendor/doctrine-common/lib',
'db.dbal.class_path' => __DIR__.'/../../../../vendor/doctrine-dbal/lib',
......
......@@ -9,21 +9,21 @@
* with this source code in the file LICENSE.
*/
namespace Silex\Tests\Extension;
namespace Silex\Tests\Provider;
use Monolog\Handler\TestHandler;
use Silex\Application;
use Silex\Extension\MonologExtension;
use Silex\Provider\MonologProvider;
use Symfony\Component\HttpFoundation\Request;
/**
* MonologExtension test cases.
* MonologProvider test cases.
*
* @author Igor Wiedler <igor@wiedler.ch>
*/
class MonologExtensionTest extends \PHPUnit_Framework_TestCase
class MonologProviderTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
......@@ -36,7 +36,7 @@ class MonologExtensionTest extends \PHPUnit_Framework_TestCase
{
$app = new Application();
$app->register(new MonologExtension(), array(
$app->register(new MonologProvider(), array(
'monolog.class_path' => __DIR__.'/../../../../vendor/monolog/src',
));
......
......@@ -9,26 +9,26 @@
* with this source code in the file LICENSE.
*/
namespace Silex\Tests\Extension;
namespace Silex\Tests\Provider;
use Silex\Application;
use Silex\Extension\SessionExtension;
use Silex\Provider\SessionProvider;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\SessionStorage\ArraySessionStorage;
/**
* SessionExtension test cases.
* SessionProvider test cases.
*
* @author Igor Wiedler <igor@wiedler.ch>
*/
class SessionExtensionTest extends \PHPUnit_Framework_TestCase
class SessionProviderTest extends \PHPUnit_Framework_TestCase
{
public function testRegister()
{
$app = new Application();
$app->register(new SessionExtension());
$app->register(new SessionProvider());
$app['session.storage'] = $app->share(function () use ($app) {
return new ArraySessionStorage();
......
......@@ -9,19 +9,19 @@
* with this source code in the file LICENSE.
*/
namespace Silex\Tests\Extension;
namespace Silex\Tests\Provider;
use Silex\Application;
use Silex\Extension\TwigExtension;
use Silex\Provider\TwigProvider;
use Symfony\Component\HttpFoundation\Request;
/**
* TwigExtension test cases.
* TwigProvider test cases.
*
* @author Igor Wiedler <igor@wiedler.ch>
*/
class TwigExtensionTest extends \PHPUnit_Framework_TestCase
class TwigProviderTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
......@@ -34,7 +34,7 @@ class TwigExtensionTest extends \PHPUnit_Framework_TestCase
{
$app = new Application();
$app->register(new TwigExtension(), array(
$app->register(new TwigProvider(), array(
'twig.templates' => array('hello' => 'Hello {{ name }}!'),
'twig.class_path' => __DIR__.'/../../../../vendor/twig/lib',
));
......
......@@ -9,25 +9,25 @@
* with this source code in the file LICENSE.
*/
namespace Silex\Tests\Extension;
namespace Silex\Tests\Provider;
use Silex\Application;
use Silex\Extension\UrlGeneratorExtension;
use Silex\Provider\UrlGeneratorProvider;
use Symfony\Component\HttpFoundation\Request;
/**
* UrlGeneratorExtension test cases.
* UrlGeneratorProvider test cases.
*
* @author Igor Wiedler <igor@wiedler.ch>
*/
class UrlGeneratorExtensionTest extends \PHPUnit_Framework_TestCase
class UrlGeneratorProviderTest extends \PHPUnit_Framework_TestCase
{
public function testRegister()
{
$app = new Application();
$app->register(new UrlGeneratorExtension());
$app->register(new UrlGeneratorProvider());
$app->get('/hello/{name}', function ($name) {})
->bind('hello');
......@@ -44,7 +44,7 @@ class UrlGeneratorExtensionTest extends \PHPUnit_Framework_TestCase
{
$app = new Application();
$app->register(new UrlGeneratorExtension());
$app->register(new UrlGeneratorProvider());
$app->get('/hello/{name}', function ($name) {})
->bind('hello');
......@@ -63,7 +63,7 @@ class UrlGeneratorExtensionTest extends \PHPUnit_Framework_TestCase
{
$app = new Application();
$app->register(new UrlGeneratorExtension());
$app->register(new UrlGeneratorProvider());
$app->get('/hello/{name}', function ($name) {})
->bind('hello');
......@@ -82,7 +82,7 @@ class UrlGeneratorExtensionTest extends \PHPUnit_Framework_TestCase
{
$app = new Application();
$app->register(new UrlGeneratorExtension());
$app->register(new UrlGeneratorProvider());
$app->get('/insecure', function () {})
->bind('insecure_page')
......@@ -102,7 +102,7 @@ class UrlGeneratorExtensionTest extends \PHPUnit_Framework_TestCase
{
$app = new Application();
$app->register(new UrlGeneratorExtension());
$app->register(new UrlGeneratorProvider());
$app->get('/secure', function () {})
->bind('secure_page')
......
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