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

upgraded to Pimple 2.1

parent 322dbb5d
...@@ -4,6 +4,7 @@ Changelog ...@@ -4,6 +4,7 @@ Changelog
2.0.0 (2013-XX-XX) 2.0.0 (2013-XX-XX)
------------------ ------------------
* Updated Pimple to 2.1
* Updated session listeners to extends HttpKernel ones * Updated session listeners to extends HttpKernel ones
* [BC BREAK] Locale management has been moved to LocaleServiceProvider which must be registered * [BC BREAK] Locale management has been moved to LocaleServiceProvider which must be registered
if you want Silex to manage your locale (must also be registered for the translation service provider) if you want Silex to manage your locale (must also be registered for the translation service provider)
......
...@@ -63,10 +63,10 @@ Pimple is probably the simplest service container out there. It makes strong ...@@ -63,10 +63,10 @@ Pimple is probably the simplest service container out there. It makes strong
use of closures and implements the ArrayAccess interface. use of closures and implements the ArrayAccess interface.
We will start off by creating a new instance of Pimple -- and because We will start off by creating a new instance of Pimple -- and because
``Silex\Application`` extends ``Pimple`` all of this applies to Silex as ``Silex\Application`` extends ``Pimple\Container`` all of this applies to Silex
well:: as well::
$container = new Pimple(); $container = new Pimple\Container();
or:: or::
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
namespace Silex\Api; namespace Silex\Api;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Pimple\Container;
/** /**
* Interface for event listener providers. * Interface for event listener providers.
...@@ -20,5 +21,5 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; ...@@ -20,5 +21,5 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
*/ */
interface EventListenerProviderInterface interface EventListenerProviderInterface
{ {
public function subscribe(\Pimple $app, EventDispatcherInterface $dispatcher); public function subscribe(Container $app, EventDispatcherInterface $dispatcher);
} }
<?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;
/**
* Interface that all Silex service providers must implement.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
interface ServiceProviderInterface
{
/**
* Registers services on the given Pimple container.
*
* This method should only be used to configure services and parameters.
* It should not get services.
*
* @param Pimple $app A Pimple instance
*/
public function register(\Pimple $app);
}
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
namespace Silex; namespace Silex;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\HttpKernelInterface;
...@@ -31,7 +33,6 @@ use Symfony\Component\Routing\RouteCollection; ...@@ -31,7 +33,6 @@ use Symfony\Component\Routing\RouteCollection;
use Silex\Api\BootableProviderInterface; use Silex\Api\BootableProviderInterface;
use Silex\Api\EventListenerProviderInterface; use Silex\Api\EventListenerProviderInterface;
use Silex\Api\ControllerProviderInterface; use Silex\Api\ControllerProviderInterface;
use Silex\Api\ServiceProviderInterface;
use Silex\EventListener\MiddlewareListener; use Silex\EventListener\MiddlewareListener;
use Silex\EventListener\ConverterListener; use Silex\EventListener\ConverterListener;
use Silex\EventListener\StringToResponseListener; use Silex\EventListener\StringToResponseListener;
...@@ -42,7 +43,7 @@ use Silex\Provider\RoutingServiceProvider; ...@@ -42,7 +43,7 @@ use Silex\Provider\RoutingServiceProvider;
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
*/ */
class Application extends \Pimple implements HttpKernelInterface, TerminableInterface class Application extends Container implements HttpKernelInterface, TerminableInterface
{ {
const VERSION = '2.0.0-DEV'; const VERSION = '2.0.0-DEV';
......
...@@ -11,13 +11,15 @@ ...@@ -11,13 +11,15 @@
namespace Silex; namespace Silex;
use Pimple\Container;
class CallbackResolver class CallbackResolver
{ {
const SERVICE_PATTERN = "/[A-Za-z0-9\._\-]+:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/"; const SERVICE_PATTERN = "/[A-Za-z0-9\._\-]+:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/";
private $app; private $app;
public function __construct(\Pimple $app) public function __construct(Container $app)
{ {
$this->app = $app; $this->app = $app;
} }
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Configuration;
use Doctrine\Common\EventManager; use Doctrine\Common\EventManager;
...@@ -24,7 +25,7 @@ use Symfony\Bridge\Doctrine\Logger\DbalLogger; ...@@ -24,7 +25,7 @@ use Symfony\Bridge\Doctrine\Logger\DbalLogger;
*/ */
class DoctrineServiceProvider implements ServiceProviderInterface class DoctrineServiceProvider implements ServiceProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['db.default_options'] = array( $app['db.default_options'] = array(
'driver' => 'pdo_mysql', 'driver' => 'pdo_mysql',
...@@ -62,7 +63,7 @@ class DoctrineServiceProvider implements ServiceProviderInterface ...@@ -62,7 +63,7 @@ class DoctrineServiceProvider implements ServiceProviderInterface
$app['dbs'] = function ($app) { $app['dbs'] = function ($app) {
$app['dbs.options.initializer'](); $app['dbs.options.initializer']();
$dbs = new \Pimple(); $dbs = new Container();
foreach ($app['dbs.options'] as $name => $options) { foreach ($app['dbs.options'] as $name => $options) {
if ($app['dbs.default'] === $name) { if ($app['dbs.default'] === $name) {
// we use shortcuts here in case the default has been overridden // we use shortcuts here in case the default has been overridden
...@@ -84,7 +85,7 @@ class DoctrineServiceProvider implements ServiceProviderInterface ...@@ -84,7 +85,7 @@ class DoctrineServiceProvider implements ServiceProviderInterface
$app['dbs.config'] = function ($app) { $app['dbs.config'] = function ($app) {
$app['dbs.options.initializer'](); $app['dbs.options.initializer']();
$configs = new \Pimple(); $configs = new Container();
foreach ($app['dbs.options'] as $name => $options) { foreach ($app['dbs.options'] as $name => $options) {
$configs[$name] = new Configuration(); $configs[$name] = new Configuration();
...@@ -99,7 +100,7 @@ class DoctrineServiceProvider implements ServiceProviderInterface ...@@ -99,7 +100,7 @@ class DoctrineServiceProvider implements ServiceProviderInterface
$app['dbs.event_manager'] = function ($app) { $app['dbs.event_manager'] = function ($app) {
$app['dbs.options.initializer'](); $app['dbs.options.initializer']();
$managers = new \Pimple(); $managers = new Container();
foreach ($app['dbs.options'] as $name => $options) { foreach ($app['dbs.options'] as $name => $options) {
$managers[$name] = new EventManager(); $managers[$name] = new EventManager();
} }
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension; use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider; use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider; use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
...@@ -27,7 +28,7 @@ use Symfony\Component\Form\ResolvedFormTypeFactory; ...@@ -27,7 +28,7 @@ use Symfony\Component\Form\ResolvedFormTypeFactory;
*/ */
class FormServiceProvider implements ServiceProviderInterface class FormServiceProvider implements ServiceProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
if (!class_exists('Locale') && !class_exists('Symfony\Component\Locale\Stub\StubLocale')) { if (!class_exists('Locale') && !class_exists('Symfony\Component\Locale\Stub\StubLocale')) {
throw new \RuntimeException('You must either install the PHP intl extension or the Symfony Locale Component to use the Form extension.'); throw new \RuntimeException('You must either install the PHP intl extension or the Symfony Locale Component to use the Form extension.');
......
...@@ -11,8 +11,9 @@ ...@@ -11,8 +11,9 @@
namespace Silex\Provider; namespace Silex\Provider;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Provider\HttpCache\HttpCache; use Silex\Provider\HttpCache\HttpCache;
use Silex\Api\ServiceProviderInterface;
use Silex\Api\EventListenerProviderInterface; use Silex\Api\EventListenerProviderInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\HttpCache\Esi; use Symfony\Component\HttpKernel\HttpCache\Esi;
...@@ -26,7 +27,7 @@ use Symfony\Component\HttpKernel\EventListener\EsiListener; ...@@ -26,7 +27,7 @@ use Symfony\Component\HttpKernel\EventListener\EsiListener;
*/ */
class HttpCacheServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface class HttpCacheServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['http_cache'] = function ($app) { $app['http_cache'] = function ($app) {
$app['http_cache.options'] = array_replace( $app['http_cache.options'] = array_replace(
...@@ -53,7 +54,7 @@ class HttpCacheServiceProvider implements ServiceProviderInterface, EventListene ...@@ -53,7 +54,7 @@ class HttpCacheServiceProvider implements ServiceProviderInterface, EventListene
$app['http_cache.options'] = array(); $app['http_cache.options'] = array();
} }
public function subscribe(\Pimple $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{ {
$dispatcher->addSubscriber($app['http_cache.esi_listener']); $dispatcher->addSubscriber($app['http_cache.esi_listener']);
} }
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Api\EventListenerProviderInterface; use Silex\Api\EventListenerProviderInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\Fragment\FragmentHandler; use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
...@@ -28,7 +29,7 @@ use Symfony\Component\HttpKernel\UriSigner; ...@@ -28,7 +29,7 @@ use Symfony\Component\HttpKernel\UriSigner;
*/ */
class HttpFragmentServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface class HttpFragmentServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['fragment.handler'] = function ($app) { $app['fragment.handler'] = function ($app) {
return new FragmentHandler($app['fragment.renderers'], isset($app['debug']) ? $app['debug'] : false, $app['request_stack']); return new FragmentHandler($app['fragment.renderers'], isset($app['debug']) ? $app['debug'] : false, $app['request_stack']);
...@@ -77,7 +78,7 @@ class HttpFragmentServiceProvider implements ServiceProviderInterface, EventList ...@@ -77,7 +78,7 @@ class HttpFragmentServiceProvider implements ServiceProviderInterface, EventList
}; };
} }
public function subscribe(\Pimple $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{ {
$dispatcher->addSubscriber($app['fragment.listener']); $dispatcher->addSubscriber($app['fragment.listener']);
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace Silex\Provider\Locale; namespace Silex\Provider\Locale;
use Pimple\Container;
use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\EventListener\LocaleListener as BaseLocaleListener; use Symfony\Component\HttpKernel\EventListener\LocaleListener as BaseLocaleListener;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
...@@ -25,7 +26,7 @@ class LocaleListener extends BaseLocaleListener ...@@ -25,7 +26,7 @@ class LocaleListener extends BaseLocaleListener
{ {
protected $app; protected $app;
public function __construct(\Pimple $app, RequestContextAwareInterface $router = null, RequestStack $requestStack = null) public function __construct(Container $app, RequestContextAwareInterface $router = null, RequestStack $requestStack = null)
{ {
parent::__construct($app['locale'], $router, $requestStack); parent::__construct($app['locale'], $router, $requestStack);
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Api\EventListenerProviderInterface; use Silex\Api\EventListenerProviderInterface;
use Silex\Provider\Locale\LocaleListener; use Silex\Provider\Locale\LocaleListener;
use Silex\Provider\Routing\LazyUrlMatcher; use Silex\Provider\Routing\LazyUrlMatcher;
...@@ -24,7 +25,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; ...@@ -24,7 +25,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
*/ */
class LocaleServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface class LocaleServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['locale.listener'] = function ($app) { $app['locale.listener'] = function ($app) {
$urlMatcher = null; $urlMatcher = null;
...@@ -40,7 +41,7 @@ class LocaleServiceProvider implements ServiceProviderInterface, EventListenerPr ...@@ -40,7 +41,7 @@ class LocaleServiceProvider implements ServiceProviderInterface, EventListenerPr
$app['locale'] = 'en'; $app['locale'] = 'en';
} }
public function subscribe(\Pimple $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{ {
$dispatcher->addSubscriber($app['locale.listener']); $dispatcher->addSubscriber($app['locale.listener']);
} }
......
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
namespace Silex\Provider; namespace Silex\Provider;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Monolog\Logger; use Monolog\Logger;
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
use Silex\Application; use Silex\Application;
use Silex\Api\ServiceProviderInterface;
use Silex\Api\BootableProviderInterface; use Silex\Api\BootableProviderInterface;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
...@@ -29,7 +30,7 @@ use Silex\EventListener\LogListener; ...@@ -29,7 +30,7 @@ use Silex\EventListener\LogListener;
*/ */
class MonologServiceProvider implements ServiceProviderInterface, BootableProviderInterface class MonologServiceProvider implements ServiceProviderInterface, BootableProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['logger'] = function () use ($app) { $app['logger'] = function () use ($app) {
return $app['monolog']; return $app['monolog'];
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Api\EventListenerProviderInterface; use Silex\Api\EventListenerProviderInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider; use Symfony\Component\Security\Core\Authentication\Provider\RememberMeAuthenticationProvider;
...@@ -26,7 +27,7 @@ use Symfony\Component\Security\Http\RememberMe\ResponseListener; ...@@ -26,7 +27,7 @@ use Symfony\Component\Security\Http\RememberMe\ResponseListener;
*/ */
class RememberMeServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface class RememberMeServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['security.remember_me.response_listener'] = function ($app) { $app['security.remember_me.response_listener'] = function ($app) {
if (!isset($app['security'])) { if (!isset($app['security'])) {
...@@ -98,7 +99,7 @@ class RememberMeServiceProvider implements ServiceProviderInterface, EventListen ...@@ -98,7 +99,7 @@ class RememberMeServiceProvider implements ServiceProviderInterface, EventListen
}); });
} }
public function subscribe(\Pimple $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{ {
$dispatcher->addSubscriber($app['security.remember_me.response_listener']); $dispatcher->addSubscriber($app['security.remember_me.response_listener']);
} }
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Api\EventListenerProviderInterface; use Silex\Api\EventListenerProviderInterface;
use Silex\Provider\Routing\RedirectableUrlMatcher; use Silex\Provider\Routing\RedirectableUrlMatcher;
use Silex\Provider\Routing\LazyUrlMatcher; use Silex\Provider\Routing\LazyUrlMatcher;
...@@ -27,7 +28,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; ...@@ -27,7 +28,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
*/ */
class RoutingServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface class RoutingServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['url_generator'] = function ($app) { $app['url_generator'] = function ($app) {
return new UrlGenerator($app['routes'], $app['request_context']); return new UrlGenerator($app['routes'], $app['request_context']);
...@@ -55,7 +56,7 @@ class RoutingServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -55,7 +56,7 @@ class RoutingServiceProvider implements ServiceProviderInterface, EventListenerP
}; };
} }
public function subscribe(\Pimple $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{ {
$dispatcher->addSubscriber($app['routing.listener']); $dispatcher->addSubscriber($app['routing.listener']);
} }
......
...@@ -11,10 +11,11 @@ ...@@ -11,10 +11,11 @@
namespace Silex\Provider; namespace Silex\Provider;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Application; use Silex\Application;
use Silex\Api\BootableProviderInterface; use Silex\Api\BootableProviderInterface;
use Silex\Api\ControllerProviderInterface; use Silex\Api\ControllerProviderInterface;
use Silex\Api\ServiceProviderInterface;
use Silex\Api\EventListenerProviderInterface; use Silex\Api\EventListenerProviderInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\RequestMatcher; use Symfony\Component\HttpFoundation\RequestMatcher;
...@@ -65,7 +66,7 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -65,7 +66,7 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
{ {
protected $fakeRoutes; protected $fakeRoutes;
public function register(\Pimple $app) public function register(Container $app)
{ {
// used to register routes for login_check and logout // used to register routes for login_check and logout
$this->fakeRoutes = array(); $this->fakeRoutes = array();
...@@ -542,7 +543,7 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener ...@@ -542,7 +543,7 @@ class SecurityServiceProvider implements ServiceProviderInterface, EventListener
} }
} }
public function subscribe(\Pimple $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{ {
$dispatcher->addSubscriber($app['security.firewall']); $dispatcher->addSubscriber($app['security.firewall']);
} }
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Symfony\Component\Serializer\Serializer; use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Encoder\XmlEncoder; use Symfony\Component\Serializer\Encoder\XmlEncoder;
...@@ -34,7 +35,7 @@ class SerializerServiceProvider implements ServiceProviderInterface ...@@ -34,7 +35,7 @@ class SerializerServiceProvider implements ServiceProviderInterface
* *
* @param Pimple $app * @param Pimple $app
*/ */
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['serializer'] = function () use ($app) { $app['serializer'] = function () use ($app) {
return new Serializer($app['serializer.normalizers'], $app['serializer.encoders']); return new Serializer($app['serializer.normalizers'], $app['serializer.encoders']);
......
...@@ -11,12 +11,13 @@ ...@@ -11,12 +11,13 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\ServiceControllerResolver; use Silex\ServiceControllerResolver;
class ServiceControllerServiceProvider implements ServiceProviderInterface class ServiceControllerServiceProvider implements ServiceProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app->extend('resolver', function ($resolver, $app) { $app->extend('resolver', function ($resolver, $app) {
return new ServiceControllerResolver($resolver, $app['callback_resolver']); return new ServiceControllerResolver($resolver, $app['callback_resolver']);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace Silex\Provider\Session; namespace Silex\Provider\Session;
use Pimple\Container;
use Symfony\Component\HttpKernel\EventListener\SessionListener as BaseSessionListener; use Symfony\Component\HttpKernel\EventListener\SessionListener as BaseSessionListener;
/** /**
...@@ -22,7 +23,7 @@ class SessionListener extends BaseSessionListener ...@@ -22,7 +23,7 @@ class SessionListener extends BaseSessionListener
{ {
private $app; private $app;
public function __construct(\Pimple $app) public function __construct(Container $app)
{ {
$this->app = $app; $this->app = $app;
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace Silex\Provider\Session; namespace Silex\Provider\Session;
use Pimple\Container;
use Symfony\Component\HttpKernel\EventListener\TestSessionListener as BaseTestSessionListener; use Symfony\Component\HttpKernel\EventListener\TestSessionListener as BaseTestSessionListener;
/** /**
...@@ -22,7 +23,7 @@ class TestSessionListener extends BaseTestSessionListener ...@@ -22,7 +23,7 @@ class TestSessionListener extends BaseTestSessionListener
{ {
private $app; private $app;
public function __construct(\Pimple $app) public function __construct(Container $app)
{ {
$this->app = $app; $this->app = $app;
} }
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Api\EventListenerProviderInterface; use Silex\Api\EventListenerProviderInterface;
use Silex\Provider\Session\SessionListener; use Silex\Provider\Session\SessionListener;
use Silex\Provider\Session\TestSessionListener; use Silex\Provider\Session\TestSessionListener;
...@@ -30,7 +31,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -30,7 +31,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP
{ {
private $app; private $app;
public function register(\Pimple $app) public function register(Container $app)
{ {
$this->app = $app; $this->app = $app;
...@@ -76,7 +77,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP ...@@ -76,7 +77,7 @@ class SessionServiceProvider implements ServiceProviderInterface, EventListenerP
$app['session.storage.save_path'] = null; $app['session.storage.save_path'] = null;
} }
public function subscribe(\Pimple $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{ {
$dispatcher->addSubscriber($app['session.listener']); $dispatcher->addSubscriber($app['session.listener']);
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Api\EventListenerProviderInterface; use Silex\Api\EventListenerProviderInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\KernelEvents;
...@@ -24,7 +25,7 @@ use Symfony\Component\HttpKernel\Event\PostResponseEvent; ...@@ -24,7 +25,7 @@ use Symfony\Component\HttpKernel\Event\PostResponseEvent;
*/ */
class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['swiftmailer.options'] = array(); $app['swiftmailer.options'] = array();
...@@ -87,7 +88,7 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe ...@@ -87,7 +88,7 @@ class SwiftmailerServiceProvider implements ServiceProviderInterface, EventListe
}; };
} }
public function subscribe(\Pimple $app, EventDispatcherInterface $dispatcher) public function subscribe(Container $app, EventDispatcherInterface $dispatcher)
{ {
$dispatcher->addListener(KernelEvents::TERMINATE, function (PostResponseEvent $event) use ($app) { $dispatcher->addListener(KernelEvents::TERMINATE, function (PostResponseEvent $event) use ($app) {
// To speed things up (by avoiding Swift Mailer initialization), flush // To speed things up (by avoiding Swift Mailer initialization), flush
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace Silex\Provider\Translation; namespace Silex\Provider\Translation;
use Pimple\Container;
use Symfony\Component\Translation\Translator as BaseTranslator; use Symfony\Component\Translation\Translator as BaseTranslator;
use Symfony\Component\Translation\MessageSelector; use Symfony\Component\Translation\MessageSelector;
...@@ -23,7 +24,7 @@ class Translator extends BaseTranslator ...@@ -23,7 +24,7 @@ class Translator extends BaseTranslator
{ {
protected $app; protected $app;
public function __construct(\Pimple $app, MessageSelector $selector) public function __construct(Container $app, MessageSelector $selector)
{ {
$this->app = $app; $this->app = $app;
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Provider\Translation\Translator; use Silex\Provider\Translation\Translator;
use Symfony\Component\Translation\MessageSelector; use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Loader\ArrayLoader; use Symfony\Component\Translation\Loader\ArrayLoader;
...@@ -24,7 +25,7 @@ use Symfony\Component\Translation\Loader\XliffFileLoader; ...@@ -24,7 +25,7 @@ use Symfony\Component\Translation\Loader\XliffFileLoader;
*/ */
class TranslationServiceProvider implements ServiceProviderInterface class TranslationServiceProvider implements ServiceProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['translator'] = function ($app) { $app['translator'] = function ($app) {
if (!isset($app['locale'])) { if (!isset($app['locale'])) {
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Symfony\Bridge\Twig\Extension\RoutingExtension; use Symfony\Bridge\Twig\Extension\RoutingExtension;
use Symfony\Bridge\Twig\Extension\TranslationExtension; use Symfony\Bridge\Twig\Extension\TranslationExtension;
use Symfony\Bridge\Twig\Extension\FormExtension; use Symfony\Bridge\Twig\Extension\FormExtension;
...@@ -27,7 +28,7 @@ use Symfony\Bridge\Twig\Form\TwigRenderer; ...@@ -27,7 +28,7 @@ use Symfony\Bridge\Twig\Form\TwigRenderer;
*/ */
class TwigServiceProvider implements ServiceProviderInterface class TwigServiceProvider implements ServiceProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['twig.options'] = array(); $app['twig.options'] = array();
$app['twig.form.templates'] = array('form_div_layout.html.twig'); $app['twig.form.templates'] = array('form_div_layout.html.twig');
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
namespace Silex\Provider\Validator; namespace Silex\Provider\Validator;
use Pimple\Container;
use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; use Symfony\Component\Validator\ConstraintValidatorFactoryInterface;
use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\ConstraintValidator;
...@@ -24,7 +25,7 @@ use Symfony\Component\Validator\ConstraintValidator; ...@@ -24,7 +25,7 @@ use Symfony\Component\Validator\ConstraintValidator;
class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface
{ {
/** /**
* @var \Pimple * @var Container
*/ */
protected $container; protected $container;
...@@ -41,10 +42,10 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface ...@@ -41,10 +42,10 @@ class ConstraintValidatorFactory implements ConstraintValidatorFactoryInterface
/** /**
* Constructor * Constructor
* *
* @param \Pimple $container DI container * @param Container $container DI container
* @param array $serviceNames Validator service names * @param array $serviceNames Validator service names
*/ */
public function __construct(\Pimple $container, array $serviceNames = array()) public function __construct(Container $container, array $serviceNames = array())
{ {
$this->container = $container; $this->container = $container;
$this->serviceNames = $serviceNames; $this->serviceNames = $serviceNames;
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
namespace Silex\Provider; namespace Silex\Provider;
use Silex\Api\ServiceProviderInterface; use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Provider\Validator\ConstraintValidatorFactory; use Silex\Provider\Validator\ConstraintValidatorFactory;
use Symfony\Component\Validator\Validator; use Symfony\Component\Validator\Validator;
use Symfony\Component\Validator\DefaultTranslator; use Symfony\Component\Validator\DefaultTranslator;
...@@ -25,7 +26,7 @@ use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader; ...@@ -25,7 +26,7 @@ use Symfony\Component\Validator\Mapping\Loader\StaticMethodLoader;
*/ */
class ValidatorServiceProvider implements ServiceProviderInterface class ValidatorServiceProvider implements ServiceProviderInterface
{ {
public function register(\Pimple $app) public function register(Container $app)
{ {
$app['validator'] = function ($app) { $app['validator'] = function ($app) {
$r = new \ReflectionClass('Symfony\Component\Validator\Validator'); $r = new \ReflectionClass('Symfony\Component\Validator\Validator');
......
...@@ -432,7 +432,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase ...@@ -432,7 +432,7 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
public function testRegisterShouldReturnSelf() public function testRegisterShouldReturnSelf()
{ {
$app = new Application(); $app = new Application();
$provider = $this->getMock('Silex\Api\ServiceProviderInterface'); $provider = $this->getMock('Pimple\ServiceProviderInterface');
$this->assertSame($app, $app->register($provider)); $this->assertSame($app, $app->register($provider));
} }
......
...@@ -11,13 +11,14 @@ ...@@ -11,13 +11,14 @@
namespace Silex\Tests; namespace Silex\Tests;
use Pimple\Container;
use Silex\CallbackResolver; use Silex\CallbackResolver;
class CallbackResolverTest extends \PHPUnit_Framework_Testcase class CallbackResolverTest extends \PHPUnit_Framework_Testcase
{ {
public function setup() public function setup()
{ {
$this->app = new \Pimple(); $this->app = new Container();
$this->resolver = new CallbackResolver($this->app); $this->resolver = new CallbackResolver($this->app);
} }
......
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